1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Bankiru\Seo\Tests\Bundle; |
4
|
|
|
|
5
|
|
|
use Bankiru\Seo\BankiruSeoEngineBundle; |
6
|
|
|
use Bankiru\Seo\Page\SeoPageInterface; |
7
|
|
|
use Symfony\Bundle\FrameworkBundle\FrameworkBundle; |
8
|
|
|
use Symfony\Bundle\FrameworkBundle\Kernel\MicroKernelTrait; |
9
|
|
|
use Symfony\Component\Config\Loader\LoaderInterface; |
10
|
|
|
use Symfony\Component\DependencyInjection\ContainerBuilder; |
11
|
|
|
use Symfony\Component\HttpFoundation\Request; |
12
|
|
|
use Symfony\Component\HttpFoundation\Response; |
13
|
|
|
use Symfony\Component\HttpKernel\Kernel; |
14
|
|
|
use Symfony\Component\Routing\RouteCollectionBuilder; |
15
|
|
|
|
16
|
|
|
final class SeoKernel extends Kernel |
17
|
|
|
{ |
18
|
|
|
use MicroKernelTrait; |
19
|
|
|
|
20
|
|
|
/** {@inheritdoc} */ |
21
|
|
|
public function registerBundles() |
22
|
|
|
{ |
23
|
|
|
return [ |
24
|
|
|
new BankiruSeoEngineBundle(), |
25
|
|
|
new FrameworkBundle(), |
26
|
|
|
]; |
27
|
|
|
} |
28
|
|
|
|
29
|
|
|
public function getCacheDir() |
30
|
|
|
{ |
31
|
|
|
return __DIR__.'/../../build/cache'; |
32
|
|
|
} |
33
|
|
|
|
34
|
|
|
public function getLogDir() |
35
|
|
|
{ |
36
|
|
|
return __DIR__.'/../../build/logs'; |
37
|
|
|
} |
38
|
|
|
|
39
|
|
|
public function eventAction(Request $request) |
40
|
|
|
{ |
41
|
|
|
/** @var SeoPageInterface $page */ |
42
|
|
|
$page = $request->attributes->get('_seo_page'); |
43
|
|
|
|
44
|
|
|
return new Response($page ? $page->getTitle() : 'not_found'); |
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
/** |
48
|
|
|
* Add or import routes into your application. |
49
|
|
|
* |
50
|
|
|
* $routes->import('config/routing.yml'); |
51
|
|
|
* $routes->add('/admin', 'AppBundle:Admin:dashboard', 'admin_dashboard'); |
52
|
|
|
* |
53
|
|
|
* @param RouteCollectionBuilder $routes |
54
|
|
|
*/ |
55
|
|
|
protected function configureRoutes(RouteCollectionBuilder $routes) |
56
|
|
|
{ |
57
|
|
|
$seoRoute = $routes->add('/test/match', 'kernel:eventAction', 'event_controller_match'); |
58
|
|
|
$seoRoute->setOption('seo', true); |
59
|
|
|
$seoRoute = $routes->add('/test/no_match', 'kernel:eventAction', 'event_controller_no_match'); |
60
|
|
|
$seoRoute->setOption('seo', true); |
61
|
|
|
$seoRoute = $routes->add('/test/no_seo', 'kernel:eventAction', 'event_controller_no_seo'); |
62
|
|
|
$seoRoute->setOption('seo', true); |
63
|
|
|
} |
64
|
|
|
|
65
|
|
|
/** {@inheritdoc} */ |
66
|
|
|
protected function configureContainer(ContainerBuilder $c, LoaderInterface $loader) |
|
|
|
|
67
|
|
|
{ |
68
|
|
|
$c->loadFromExtension('framework', ['secret' => 'test_secret', 'test' => true]); |
69
|
|
|
} |
70
|
|
|
} |
71
|
|
|
|
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.