File tree Expand file tree Collapse file tree 5 files changed +75
-5
lines changed Expand file tree Collapse file tree 5 files changed +75
-5
lines changed Original file line number Diff line number Diff line change 1+ <?php
2+
3+ declare (strict_types=1 );
4+
5+ namespace Lmc \SpiritWebTwigBundle \DependencyInjection ;
6+
7+ use Symfony \Component \Config \FileLocator ;
8+ use Symfony \Component \DependencyInjection \ContainerBuilder ;
9+ use Symfony \Component \DependencyInjection \Loader ;
10+ use Symfony \Component \HttpKernel \DependencyInjection \Extension ;
11+
12+ /**
13+ * This is the class that loads and manages your bundle configuration
14+ *
15+ * To learn more see {@link http://symfony.com/doc/current/cookbook/bundles/extension.html}
16+ */
17+ class SpiritWebTwigExtension extends Extension
18+ {
19+ public const PARAMETER_PATH = 'spirit_web_twig.path ' ;
20+
21+ public const PARAMETER_PATH_ALIAS = 'spirit_web_twig.path_alias ' ;
22+
23+ public function load (array $ configs , ContainerBuilder $ container ): void
24+ {
25+ $ configuration = new Configuration ();
26+ $ config = $ this ->processConfiguration ($ configuration , $ configs );
27+
28+ $ loader = new Loader \YamlFileLoader ($ container , new FileLocator (__DIR__ . '/../Resources/config ' ));
29+ $ loader ->load ('services.yml ' );
30+
31+ $ container ->setParameter (self ::PARAMETER_PATH , $ config ['path ' ]);
32+ $ container ->setParameter (self ::PARAMETER_PATH_ALIAS , $ config ['path_alias ' ]);
33+ }
34+ }
Original file line number Diff line number Diff line change 1414 *
1515 * To learn more see {@link http://symfony.com/doc/current/cookbook/bundles/extension.html}
1616 */
17- class TwigComponentsExtension extends Extension
17+ class SpiritWebTwigExtension extends Extension
1818{
1919 public const PARAMETER_PATH = 'spirit_web_twig.path ' ;
2020
Original file line number Diff line number Diff line change 44
55namespace Lmc \SpiritWebTwigBundle ;
66
7- use Lmc \SpiritWebTwigBundle \Compiler \ComponentLexer ;
87use Lmc \SpiritWebTwigBundle \Factory \TwigFactory ;
9- use Mockery ;
108use PHPUnit \Framework \TestCase ;
119use Twig \Environment ;
1210use Twig \Loader \FilesystemLoader ;
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ declare (strict_types=1 );
4+
5+ namespace Lmc \SpiritWebTwigBundle \DependencyInjection ;
6+
7+ use PHPUnit \Framework \TestCase ;
8+ use Symfony \Component \DependencyInjection \ContainerBuilder ;
9+
10+ class SpiritWebTwigExtensionTest extends TestCase
11+ {
12+ private ContainerBuilder $ containerBuilder ;
13+
14+ protected function setUp (): void
15+ {
16+ $ config = [
17+ 'path ' => 'templates/ ' ,
18+ 'path_alias ' => 'ui-components ' ,
19+ ];
20+
21+ $ this ->loadExtension ([$ config ]);
22+ }
23+
24+ private function loadExtension (array $ configs ): void
25+ {
26+ $ extension = new SpiritWebTwigExtension ();
27+ $ this ->containerBuilder = new ContainerBuilder ();
28+ $ this ->containerBuilder ->registerExtension ($ extension );
29+
30+ $ extension ->load ($ configs , $ this ->containerBuilder );
31+ }
32+
33+ public function testShouldRegisterParameters (): void
34+ {
35+ $ this ->assertTrue ($ this ->containerBuilder ->hasParameter ('spirit_web_twig.path ' ));
36+ $ this ->assertTrue ($ this ->containerBuilder ->hasParameter ('spirit_web_twig.path_alias ' ));
37+ }
38+ }
Original file line number Diff line number Diff line change 77use PHPUnit \Framework \TestCase ;
88use Symfony \Component \DependencyInjection \ContainerBuilder ;
99
10- class TwigComponentsExtensionTest extends TestCase
10+ class SpiritWebTwigExtensionTest extends TestCase
1111{
1212 private ContainerBuilder $ containerBuilder ;
1313
@@ -23,7 +23,7 @@ protected function setUp(): void
2323
2424 private function loadExtension (array $ configs ): void
2525 {
26- $ extension = new TwigComponentsExtension ();
26+ $ extension = new SpiritWebTwigExtension ();
2727 $ this ->containerBuilder = new ContainerBuilder ();
2828 $ this ->containerBuilder ->registerExtension ($ extension );
2929
You can’t perform that action at this time.
0 commit comments