1 | <?php |
||
29 | class AppKernel extends Kernel |
||
|
|||
30 | { |
||
31 | use MicroKernelTrait; |
||
32 | |||
33 | public function registerBundles() |
||
34 | { |
||
35 | return [ |
||
36 | new FrameworkBundle(), |
||
37 | new ResourceResolverBundle(), |
||
38 | new TwigBundle(), |
||
39 | new WebServerBundle(), |
||
40 | ]; |
||
41 | } |
||
42 | |||
43 | protected function configureRoutes(RouteCollectionBuilder $routes) |
||
44 | { |
||
45 | $routes->add('/', EngineAsArgumentController::class, 'index'); |
||
46 | $routes->add('/argument', EngineAsArgumentController::class, 'argument'); |
||
47 | $routes->add('/constructor', TemplatingController::class, 'constructor'); |
||
48 | $routes->addRoute(new Route('/variadic/request', [ |
||
49 | '_controller' => VariadicController::class, |
||
50 | '_resources' => [Identity::class, ['$request']], |
||
51 | ]), |
||
52 | 'variadic_request' |
||
53 | ); |
||
54 | } |
||
55 | |||
56 | protected function configureContainer(ContainerBuilder $c, LoaderInterface $loader) |
||
57 | { |
||
58 | //Controllers |
||
59 | $c->autowire(EngineAsArgumentController::class) |
||
60 | ->setAutoconfigured(true) |
||
61 | ->addTag('controller.service_arguments') |
||
62 | ->setPublic(true); |
||
63 | |||
64 | $c->autowire(TemplatingController::class) |
||
65 | ->setAutoconfigured(true) |
||
66 | // ->addTag('controller.service_arguments') |
||
67 | ->setPublic(true); |
||
68 | |||
69 | $c->autowire(VariadicController::class) |
||
70 | ->setAutoconfigured(true) |
||
71 | ->setPublic(true); |
||
72 | |||
73 | $c->autowire(Identity::class) |
||
74 | ->setAutoconfigured(true) |
||
75 | ->setPublic(true); |
||
76 | |||
77 | // Extensions |
||
78 | $c->loadFromExtension('framework', [ |
||
79 | 'secret' => 'NotSecret', // What about use $ uuid -v4 or $ uuidgen |
||
80 | 'test' => in_array($this->getEnvironment(), ['test'], true), // test.client service for eg. PHPUnit |
||
81 | 'templating' => ['engines' => 'twig'], |
||
82 | ]); |
||
83 | $c->loadFromExtension('twig', [ |
||
84 | 'debug' => true, |
||
85 | 'paths' => ['%kernel.project_dir%/tests/templates'], |
||
86 | ]); |
||
87 | } |
||
88 | } |
||
89 |
This check looks for classes that have been defined more than once.
If you can, we would recommend to use standard object-oriented programming techniques. For example, to avoid multiple types, it might make sense to create a common interface, and then multiple, different implementations for that interface.
This also has the side-effect of providing you with better IDE auto-completion, static analysis and also better OPCode caching from PHP.