Test Failed
Push — master ( bbd0e4...a046eb )
by Jean-Bernard
01:56
created

ComponentKernel::configureRoutes()   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 1
1
<?php
2
3
/*
4
 * This file is part of the Symfony-Util package.
5
 *
6
 * (c) Jean-Bernard Addor
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
use Symfony\Bridge\Twig\TwigEngine;
13
use Symfony\Bundle\FrameworkBundle\Client;
14
use Symfony\Bundle\FrameworkBundle\FrameworkBundle;
15
use Symfony\Bundle\FrameworkBundle\Kernel\MicroKernelTrait;
16
// use Symfony\Bundle\TwigBundle\TwigBundle;
17
use Symfony\Component\Config\Loader\LoaderInterface;
18
use Symfony\Component\DependencyInjection\ContainerBuilder;
19
use Symfony\Component\HttpKernel\Kernel;
20
use Symfony\Component\Routing\RouteCollectionBuilder;
21
use Symfony\Component\Templating\EngineInterface;
22
use Symfony\Component\Templating\TemplateNameParser;
23
use Symfony\Component\Templating\TemplateNameParserInterface;
24
use SymfonyUtil\Controller\EngineAsArgumentController;
25
26
// use Twig_Environment;
0 ignored issues
show
Unused Code Comprehensibility introduced by
37% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
27
// use Twig_Loader_Array;
28
29
class ComponentKernel extends Kernel
30
{
31
    use MicroKernelTrait;
32
33
    public function registerBundles()
34
    {
35
        return [
36
            new FrameworkBundle(),
37
            // new TwigBundle(),
0 ignored issues
show
Unused Code Comprehensibility introduced by
58% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
38
        ];
39
    }
40
41
    protected function configureRoutes(RouteCollectionBuilder $routes)
42
    {
43
        $routes->add('/', EngineAsArgumentController::class, 'index');
44
    }
45
46
    protected function configureContainer(ContainerBuilder $c, LoaderInterface $loader)
0 ignored issues
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...
47
    {
48
        // https://symfony.com/doc/current/service_container.html
49
        $c->autowire(TemplateNameParser::class)
50
            ->setAutoconfigured(true)
51
            ->setPublic(false);
52
        $c->setAlias(TemplateNameParserInterface::class, TemplateNameParser::class);
53
54
        $c->autowire(Twig_Loader_Array::class, Twig_Loader_Array::class)
55
            ->setArgument('$templates', ['index.html.twig' => 'Hello Component!'])
56
            ->setAutoconfigured(true)
57
            ->setPublic(false);
58
        $c->setAlias(Twig_LoaderInterface::class, Twig_Loader_Array::class);
59
60
        $c->autowire(Twig_Environment::class, Twig_Environment::class)
61
            ->setAutoconfigured(true)
62
            ->setPublic(false);
63
        $c->setAlias(Twig\Environment::class, Twig_Environment::class);
64
65
        $c->autowire(TwigEngine::class)
66
            ->setAutoconfigured(true)
67
            ->setShared(true) // not needed: default
68
            ->setPublic(false);
69
        $c->setAlias(EngineInterface::class, TwigEngine::class);
70
71
        if (in_array($this->getEnvironment(), ['test'], true)) {
72
            $c->autowire('test.client', Client::class)
73
                ->setAutoconfigured(false)
74
                ->setShared(false)
75
                ->setPublic(true); //
76
        }
77
78
        //Controllers
79
        $c->autowire(EngineAsArgumentController::class)
80
            ->setAutoconfigured(true)
81
            ->addTag('controller.service_arguments')
82
            ->setPublic(false);
83
84
        // Extensions
85
        $c->loadFromExtension('framework', [
86
            'secret' => 'NotSecret', // What about use $ uuid -v4  or $ uuidgen
87
            'test' => in_array($this->getEnvironment(), ['test'], true), // test.client service for eg. PHPUnit
88
            // 'templating' => ['engines' => 'twig'],
0 ignored issues
show
Unused Code Comprehensibility introduced by
62% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
89
        ]);
90
        // $c->loadFromExtension('twig', [
0 ignored issues
show
Unused Code Comprehensibility introduced by
67% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
91
        //     'debug' => true,
0 ignored issues
show
Unused Code Comprehensibility introduced by
43% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
92
        //     'paths' => ['%kernel.project_dir%/tests/templates'],
0 ignored issues
show
Unused Code Comprehensibility introduced by
67% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
93
        // ]);
94
    }
95
}
96
97
// Information for Service "test.client"
98
// =====================================
99
100
//  ---------------- --------------------------------------- 
101
//   Option           Value                                  
102
//  ---------------- --------------------------------------- 
103
//   Service ID       test.client                            
104
//   Class            Symfony\Bundle\FrameworkBundle\Client  
105
//   Tags             -                                      
106
//   Public           yes                                    
107
//   Synthetic        no                                     
108
//   Lazy             no                                     
109
//   Shared           no                                     
110
//   Abstract         no                                     
111
//   Autowired        no                                     
112
//   Autoconfigured   no                                     
113
//  ---------------- --------------------------------------- 
114