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\Component\Config\Loader\LoaderInterface; |
17
|
|
|
use Symfony\Component\DependencyInjection\ContainerBuilder; |
18
|
|
|
use Symfony\Component\HttpKernel\Kernel; |
19
|
|
|
use Symfony\Component\Routing\RouteCollectionBuilder; |
20
|
|
|
use Symfony\Component\Templating\EngineInterface; |
21
|
|
|
use Symfony\Component\Templating\TemplateNameParser; |
22
|
|
|
use Symfony\Component\Templating\TemplateNameParserInterface; |
23
|
|
|
use SymfonyUtil\Controller\EngineAsArgumentController; |
24
|
|
|
use SymfonyUtil\Controller\TemplatingController; |
25
|
|
|
|
26
|
|
|
// use Twig_Environment; |
27
|
|
|
// use Twig_Loader_Array; |
28
|
|
|
|
29
|
|
|
class AppKernel extends Kernel |
30
|
|
|
{ |
31
|
|
|
use MicroKernelTrait; |
32
|
|
|
|
33
|
|
|
public function registerBundles() |
34
|
|
|
{ |
35
|
|
|
return [ |
36
|
|
|
new FrameworkBundle(), |
37
|
|
|
]; |
38
|
|
|
} |
39
|
|
|
|
40
|
|
|
protected function configureRoutes(RouteCollectionBuilder $routes) |
41
|
|
|
{ |
42
|
|
|
$routes->add('/', EngineAsArgumentController::class, 'index'); |
43
|
|
|
$routes->add('/argument', EngineAsArgumentController::class, 'argument'); |
44
|
|
|
$routes->add('/constructor', TemplatingController::class, 'constructor'); |
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
protected function configureContainer(ContainerBuilder $c, LoaderInterface $loader) |
|
|
|
|
48
|
|
|
{ |
49
|
|
|
// https://symfony.com/doc/current/service_container.html |
50
|
|
|
$c->autowire(TemplateNameParser::class) |
51
|
|
|
->setAutoconfigured(true) |
52
|
|
|
->setPublic(false); |
53
|
|
|
$c->setAlias(TemplateNameParserInterface::class, TemplateNameParser::class); |
54
|
|
|
|
55
|
|
|
$c->autowire(Twig_Loader_Array::class, Twig_Loader_Array::class) |
56
|
|
|
->setArgument('$templates', ['index.html.twig' => 'Hello Component!']) |
57
|
|
|
->setAutoconfigured(true) |
58
|
|
|
->setPublic(false); |
59
|
|
|
$c->setAlias(Twig_LoaderInterface::class, Twig_Loader_Array::class); |
60
|
|
|
|
61
|
|
|
$c->autowire(Twig_Environment::class, Twig_Environment::class) |
62
|
|
|
->setAutoconfigured(true) |
63
|
|
|
->setPublic(false); |
64
|
|
|
$c->setAlias(Twig\Environment::class, Twig_Environment::class); |
65
|
|
|
|
66
|
|
|
$c->autowire(TwigEngine::class) |
67
|
|
|
->setAutoconfigured(true) |
68
|
|
|
->setPublic(false); |
69
|
|
|
$c->setAlias(EngineInterface::class, TwigEngine::class); |
70
|
|
|
|
71
|
|
View Code Duplication |
if (in_array($this->getEnvironment(), ['test'], true)) { |
|
|
|
|
72
|
|
|
$c->autowire('test.client', Client::class) |
73
|
|
|
->setPublic(true); // Public needed! |
74
|
|
|
} |
75
|
|
|
|
76
|
|
|
//Controllers |
77
|
|
|
$c->autowire(EngineAsArgumentController::class) |
78
|
|
|
->setAutoconfigured(true) |
79
|
|
|
->addTag('controller.service_arguments') |
80
|
|
|
->setPublic(true); |
81
|
|
|
|
82
|
|
|
$c->autowire(TemplatingController::class) |
83
|
|
|
->setAutoconfigured(true) |
84
|
|
|
// ->addTag('controller.service_arguments') |
85
|
|
|
->setPublic(true); |
86
|
|
|
|
87
|
|
|
// Extensions |
88
|
|
|
$c->loadFromExtension('framework', [ |
89
|
|
|
'secret' => 'NotSecret', // What about use $ uuid -v4 or $ uuidgen |
90
|
|
|
]); |
91
|
|
|
} |
92
|
|
|
} |
93
|
|
|
|
94
|
|
|
// Information for Service "test.client" |
95
|
|
|
// ===================================== |
96
|
|
|
|
97
|
|
|
// ---------------- --------------------------------------- |
98
|
|
|
// Option Value |
99
|
|
|
// ---------------- --------------------------------------- |
100
|
|
|
// Service ID test.client |
101
|
|
|
// Class Symfony\Bundle\FrameworkBundle\Client |
102
|
|
|
// Tags - |
103
|
|
|
// Public yes |
104
|
|
|
// Synthetic no |
105
|
|
|
// Lazy no |
106
|
|
|
// Shared no |
107
|
|
|
// Abstract no |
108
|
|
|
// Autowired no |
109
|
|
|
// Autoconfigured no |
110
|
|
|
// ---------------- --------------------------------------- |
111
|
|
|
|
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.