Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
druidvav committed May 12, 2016
0 parents commit 6a91ad1
Showing 6 changed files with 69 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.idea
composer.lock
vendor
16 changes: 16 additions & 0 deletions composer.json
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.*"
}
}
20 changes: 20 additions & 0 deletions src/Druidvav/CrawlerDetectBundle/CrawlerDetect.php
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'));
}
}
8 changes: 8 additions & 0 deletions src/Druidvav/CrawlerDetectBundle/CrawlerDetectBundle.php
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
{
}
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');
}
}
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

0 comments on commit 6a91ad1

Please sign in to comment.