Skip to content

Commit 85ce5c4

Browse files
committed
Stelle von XML- auf PHP-basierte Service Konfiguration um
1 parent 4e782da commit 85ce5c4

File tree

5 files changed

+98
-99
lines changed

5 files changed

+98
-99
lines changed

src/DependencyInjection/WebfactoryShortcodeExtension.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
use Symfony\Component\DependencyInjection\ChildDefinition;
77
use Symfony\Component\DependencyInjection\ContainerBuilder;
88
use Symfony\Component\DependencyInjection\Extension\Extension;
9-
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
9+
use Symfony\Component\DependencyInjection\Loader\PhpFileLoader;
1010

1111
/**
1212
* Loads the bundle configuration.
@@ -15,9 +15,9 @@ final class WebfactoryShortcodeExtension extends Extension
1515
{
1616
public function load(array $configs, ContainerBuilder $container): void
1717
{
18-
$loader = new XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
19-
$loader->load('shortcodes.xml');
20-
$loader->load('guide.xml');
18+
$loader = new PhpFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
19+
$loader->load('shortcodes.php');
20+
$loader->load('guide.php');
2121

2222
$configuration = new Configuration();
2323
$config = $this->processConfiguration($configuration, $configs);

src/Resources/config/guide.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?php
2+
3+
namespace Symfony\Component\DependencyInjection\Loader\Configurator;
4+
5+
return static function(ContainerConfigurator $container) {
6+
$services = $container->services();
7+
$parameters = $container->parameters();
8+
9+
$services->defaults()
10+
->autowire()
11+
->autoconfigure();
12+
13+
$services->set(\Webfactory\ShortcodeBundle\Controller\GuideController::class)
14+
->args([
15+
'',
16+
service('twig'),
17+
])
18+
->tag('controller.service_arguments');
19+
};

src/Resources/config/guide.xml

Lines changed: 0 additions & 17 deletions
This file was deleted.
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
<?php
2+
3+
namespace Symfony\Component\DependencyInjection\Loader\Configurator;
4+
5+
return static function(ContainerConfigurator $container) {
6+
$services = $container->services();
7+
$parameters = $container->parameters();
8+
9+
$services->defaults()
10+
->private();
11+
12+
$services->set(\Thunder\Shortcode\HandlerContainer\HandlerContainer::class);
13+
14+
$services->set('webfactory_shortcode.regular_parser', \Thunder\Shortcode\Parser\RegularParser::class);
15+
16+
$services->set('webfactory_shortcode.regex_parser', \Thunder\Shortcode\Parser\RegexParser::class);
17+
18+
$services->set(\Webfactory\ShortcodeBundle\Factory\ProcessorFactory::class)
19+
->args([
20+
service('webfactory_shortcode.parser'),
21+
service(\Thunder\Shortcode\HandlerContainer\HandlerContainer::class),
22+
service(\Thunder\Shortcode\EventContainer\EventContainer::class),
23+
'%webfactory_shortcode.recursion_depth%',
24+
'%webfactory_shortcode.max_iterations%',
25+
]);
26+
27+
$services->set(\Thunder\Shortcode\Processor\Processor::class)
28+
->public()
29+
->factory([service(\Webfactory\ShortcodeBundle\Factory\ProcessorFactory::class), 'create']);
30+
31+
$services->set(\Thunder\Shortcode\EventContainer\EventContainer::class)
32+
->call('addListener', [
33+
\Thunder\Shortcode\Events::REPLACE_SHORTCODES,
34+
inline_service(\Webfactory\ShortcodeBundle\Handler\RemoveWrappingParagraphElementsEventHandler::class),
35+
]);
36+
37+
$services->set('Webfactory\ShortcodeBundle\Handler\EmbeddedShortcodeHandler.esi', \Webfactory\ShortcodeBundle\Handler\EmbeddedShortcodeHandler::class)
38+
->abstract()
39+
->lazy()
40+
->args([
41+
service('fragment.handler'),
42+
'',
43+
'esi',
44+
service('request_stack'),
45+
service('logger')->nullOnInvalid(),
46+
])
47+
->tag('monolog.logger', ['channel' => 'shortcode']);
48+
49+
$services->alias('webfactory.shortcode.embed_esi_for_shortcode_handler', 'Webfactory\ShortcodeBundle\Handler\EmbeddedShortcodeHandler.esi');
50+
51+
$services->set('Webfactory\ShortcodeBundle\Handler\EmbeddedShortcodeHandler.inline', \Webfactory\ShortcodeBundle\Handler\EmbeddedShortcodeHandler::class)
52+
->abstract()
53+
->lazy()
54+
->args([
55+
service('fragment.handler'),
56+
'',
57+
'inline',
58+
service('request_stack'),
59+
service('logger')->nullOnInvalid(),
60+
])
61+
->tag('monolog.logger', ['channel' => 'shortcode']);
62+
63+
$services->alias('webfactory.shortcode.embed_inline_for_shortcode_handler', 'Webfactory\ShortcodeBundle\Handler\EmbeddedShortcodeHandler.inline');
64+
65+
$services->set(\Webfactory\ShortcodeBundle\Twig\ShortcodeExtension::class, \Webfactory\ShortcodeBundle\Twig\ShortcodeExtension::class)
66+
->args([service(\Thunder\Shortcode\Processor\Processor::class)])
67+
->tag('twig.extension');
68+
69+
$services->set(\Webfactory\ShortcodeBundle\Test\ShortcodeDefinitionTestHelper::class)
70+
->public()
71+
->args([
72+
service('controller_resolver'),
73+
service(\Thunder\Shortcode\HandlerContainer\HandlerContainer::class),
74+
]);
75+
};

src/Resources/config/shortcodes.xml

Lines changed: 0 additions & 78 deletions
This file was deleted.

0 commit comments

Comments
 (0)