-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
0 parents
commit 6a91ad1
Showing
6 changed files
with
69 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
.idea | ||
composer.lock | ||
vendor |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{ | ||
"name": "druidvav/crawler-detect-bundle", | ||
"type": "symfony-bundle", | ||
"license": "MIT", | ||
"description": "", | ||
"autoload": { | ||
"psr-4": { "": "src/" } | ||
}, | ||
"require": { | ||
"php": ">=5.6.0", | ||
"symfony/framework-bundle": "~2.6|~3.0", | ||
"symfony/twig-bundle": "~2.6|~3.0", | ||
"symfony/form": "~2.6|~3.0", | ||
"jaybizzle/crawler-detect": "1.*" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?php | ||
namespace Druidvav\CrawlerDetectBundle; | ||
|
||
use Jaybizzle\CrawlerDetect\CrawlerDetect as JayCrawlerDetect; | ||
use Symfony\Component\HttpFoundation\Request; | ||
|
||
class CrawlerDetect | ||
{ | ||
protected $detect; | ||
|
||
public function __construct(JayCrawlerDetect $detect) | ||
{ | ||
$this->detect = $detect; | ||
} | ||
|
||
public function isCrawler(Request $request) | ||
{ | ||
return $this->detect->isCrawler($request->headers->get('User-Agent')); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<?php | ||
namespace Druidvav\CrawlerDetectBundle; | ||
|
||
use Symfony\Component\HttpKernel\Bundle\Bundle; | ||
|
||
class CrawlerDetectBundle extends Bundle | ||
{ | ||
} |
16 changes: 16 additions & 0 deletions
16
src/Druidvav/CrawlerDetectBundle/DependencyInjection/DruidvavCrawlerDetectExtension.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<?php | ||
namespace Druidvav\CrawlerDetectBundle\DependencyInjection; | ||
|
||
use Symfony\Component\DependencyInjection\ContainerBuilder; | ||
use Symfony\Component\DependencyInjection\Loader\YamlFileLoader; | ||
use Symfony\Component\HttpKernel\DependencyInjection\Extension; | ||
use Symfony\Component\Config\FileLocator; | ||
|
||
class DruidvavCrawlerDetectExtension extends Extension | ||
{ | ||
public function load(array $configs, ContainerBuilder $container) | ||
{ | ||
$loader = new YamlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config')); | ||
$loader->load('services.yml'); | ||
} | ||
} |
6 changes: 6 additions & 0 deletions
6
src/Druidvav/CrawlerDetectBundle/Resources/config/services.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
services: | ||
dv.crawler_detect: | ||
class: Druidvav\CrawlerDetectBundle\CrawlerDetect | ||
arguments: [ "@dv.crawler_detect.service" ] | ||
dv.crawler_detect.service: | ||
class: Jaybizzle\CrawlerDetect\CrawlerDetect |