Completed
Push — master ( 51af85...b489fc )
by Pavel
06:35
created

SeoKernel::getCacheDir()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
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)
1 ignored issue
show
Unused Code introduced by
The parameter $loader is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
67
    {
68
        $c->loadFromExtension('framework', ['secret' => 'test_secret', 'test' => true]);
69
    }
70
}
71