8000 [Workflow] Move twig extension registration to twig bundle · symfony/symfony@3fc80d1 · GitHub
[go: up one dir, main page]

Skip to content

Commit 3fc80d1

Browse files
committed
[Workflow] Move twig extension registration to twig bundle
1 parent b8714d3 commit 3fc80d1

File tree

3 files changed

+12
-5
lines changed

3 files changed

+12
-5
lines changed

src/Symfony/Bundle/FrameworkBundle/Resources/config/workflow.xml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,5 @@
2222
<service id="workflow.marking_store.single_state" class="Symfony\Component\Workflow\MarkingStore\SingleStateMarkingStore" abstract="true" />
2323

2424
<service id="workflow.registry" class="Symfony\Component\Workflow\Registry" />
25-
26-
<service id="workflow.twig_extension" 10000 class="Symfony\Bridge\Twig\Extension\WorkflowExtension">
27-
<argument type="service" id="workflow.registry" />
28-
<tag name="twig.extension" />
29-
</service>
3025
</services>
3126
</container>

src/Symfony/Bundle/TwigBundle/DependencyInjection/Compiler/ExtensionPass.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
use Symfony\Component\DependencyInjection\Reference;
1919
use Symfony\Component\ExpressionLanguage\ExpressionLanguage;
2020
use Symfony\Component\Stopwatch\Stopwatch;
21+
use Symfony\Component\Workflow\Workflow;
2122
use Symfony\Component\Yaml\Parser as YamlParser;
2223

2324
/**
@@ -115,6 +116,13 @@ public function process(ContainerBuilder $container)
115116
if (class_exists(ExpressionLanguage::class)) {
116117
$container->getDefinition('twig.extension.expression')->addTag('twig.extension');
117118
}
119+
120+
$container->addResource(new ClassExistenceResource(Workflow::class));
121+
if (!class_exists(Workflow::class) || !$container->has('workflow.registry')) {
122+
$container->removeDefinition('workflow.twig_extension');
123+
} else {
124+
$container->getDefinition('workflow.twig_extension')->addTag('twig.extension');
125+
}
118126
}
119127

120128
private function getComposerRootDir($rootDir)

src/Symfony/Bundle/TwigBundle/Resources/config/twig.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,10 @@
106106

107107
<service id="twig.extension.debug" class="Twig_Extension_Debug" public="false" />
108108

109+
<service id="workflow.twig_extension" class="Symfony\Bridge\Twig\Extension\WorkflowExtension">
110+
<argument type="service" id="workflow.registry" />
111+
</service>
112+
109113
<service id="twig.translation.extractor" class="Symfony\Bridge\Twig\Translation\TwigExtractor">
110114
<argument type="service" id="twig" />
111115
<tag name="translation.extractor" alias="twig" />

0 commit comments

Comments
 (0)
0