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 14
14
*
15
15
* To learn more see {@link http://symfony.com/doc/current/cookbook/bundles/extension.html}
16
16
*/
17
- class TwigComponentsExtension extends Extension
17
+ class SpiritWebTwigExtension extends Extension
18
18
{
19
19
public const PARAMETER_PATH = 'spirit_web_twig.path ' ;
20
20
Original file line number Diff line number Diff line change 4
4
5
5
namespace Lmc \SpiritWebTwigBundle ;
6
6
7
- use Lmc \SpiritWebTwigBundle \Compiler \ComponentLexer ;
8
7
use Lmc \SpiritWebTwigBundle \Factory \TwigFactory ;
9
- use Mockery ;
10
8
use PHPUnit \Framework \TestCase ;
11
9
use Twig \Environment ;
12
10
use 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 7
7
use PHPUnit \Framework \TestCase ;
8
8
use Symfony \Component \DependencyInjection \ContainerBuilder ;
9
9
10
- class TwigComponentsExtensionTest extends TestCase
10
+ class SpiritWebTwigExtensionTest extends TestCase
11
11
{
12
12
private ContainerBuilder $ containerBuilder ;
13
13
@@ -23,7 +23,7 @@ protected function setUp(): void
23
23
24
24
private function loadExtension (array $ configs ): void
25
25
{
26
- $ extension = new TwigComponentsExtension ();
26
+ $ extension = new SpiritWebTwigExtension ();
27
27
$ this ->containerBuilder = new ContainerBuilder ();
28
28
$ this ->containerBuilder ->registerExtension ($ extension );
29
29
You can’t perform that action at this time.
0 commit comments