Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit f389fa3

Browse filesBrowse files
committed
bug #22652 [Workflow] Move twig extension registration to twig bundle (ogizanagi)
This PR was merged into the 3.2 branch. Discussion ---------- [Workflow] Move twig extension registration to twig bundle | Q | A | ------------- | --- | Branch? | 3.2 | Bug fix? | not really | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | N/A | License | MIT | Doc PR | N/A It's probably very late, but I think the twig extension registration is supposed to be done from the `TwigBundle` rather than the `FrameworkBundle`. Fortunately, it doesn't cause any issue currently when using the framework bundle and the workflow component without twig, because it only creates a `workflow.twig_extension` service you'll probably never call, and the `twig.extension` tag is never processed. But still, creates a useless service that cannot be called (and is not removed because it's public). So this PR aims for consistency over other twig extensions registration, and removing this service when not using twig. It isn't a BC break to me, as you usually already use the `TwigBundle` for other extensions. Commits ------- 3fc80d1 [Workflow] Move twig extension registration to twig bundle
2 parents ec92b68 + 3fc80d1 commit f389fa3
Copy full SHA for f389fa3

File tree

3 files changed

+12
-5
lines changed
Filter options

3 files changed

+12
-5
lines changed

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

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Resources/config/workflow.xml
-5Lines 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" 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

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/TwigBundle/DependencyInjection/Compiler/ExtensionPass.php
+8Lines 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

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/TwigBundle/Resources/config/twig.xml
+4Lines 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)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.