8000 [Workflow] Move twig extension registration to twig bundle by ogizanagi · Pull Request #22652 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[Workflow] Move twig extension registration to twig bundle #22652

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 8, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,5 @@
<service id="workflow.marking_store.single_state" class="Symfony\Component\Workflow\MarkingStore\SingleStateMarkingStore" abstract="true" />

<service id="workflow.registry" class="Symfony\Component\Workflow\Registry" />

<service id="workflow.twig_extension" class="Symfony\Bridge\Twig\Extension\WorkflowExtension">
<argument type="service" id="workflow.registry" />
<tag name="twig.extension" />
</service>
</services>
</container>
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
use Symfony\Component\DependencyInjection\Reference;
use Symfony\Component\ExpressionLanguage\ExpressionLanguage;
use Symfony\Component\Stopwatch\Stopwatch;
use Symfony\Component\Workflow\Workflow;
use Symfony\Component\Yaml\Parser as YamlParser;

/**
Expand Down Expand Up @@ -115,6 +116,13 @@ public function process(ContainerBuilder $container)
if (class_exists(ExpressionLanguage::class)) {
$container->getDefinition('twig.extension.expression')->addTag('twig.extension');
}

$container->addResource(new ClassExistenceResource(Workflow::class));
if (!class_exists(Workflow::class) || !$container->has('workflow.registry')) {
$container->removeDefinition('workflow.twig_extension');
} else {
$container->getDefinition('workflow.twig_extension')->addTag('twig.extension');
}
}

private function getComposerRootDir($rootDir)
Expand Down
4 changes: 4 additions & 0 deletions src/Symfony/Bundle/TwigBundle/Resources/config/twig.xml
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,10 @@

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

<service id="workflow.twig_extension" class="Symfony\Bridge\Twig\Extension\WorkflowExtension">
<argument type="service" id="workflow.registry" />
</service>

<service id="twig.translation.extractor" class="Symfony\Bridge\Twig\Translation\TwigExtractor">
<argument type="service" id="twig" />
<tag name="translation.extractor" alias="twig" />
Expand Down
0