Skip to content

Commit bdf5b81

Browse files
committed
harden the config when using workflow guards
This will forbid using the FrameworkBundle in 3.3 with previous releases of the Workflow to avoid issues related to the GuardListener class not being present. Additionally, it provides a useful exception in case the guard option is used without the ExpressionLanguage component being installed.
1 parent bfb5f8e commit bdf5b81

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

DependencyInjection/FrameworkExtension.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
use Symfony\Component\DependencyInjection\Exception\LogicException;
2626
use Symfony\Component\DependencyInjection\Reference;
2727
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
28+
use Symfony\Component\ExpressionLanguage\ExpressionLanguage;
2829
use Symfony\Component\Finder\Finder;
2930
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
3031
use Symfony\Component\Config\FileLocator;
@@ -508,6 +509,11 @@ private function registerWorkflowConfiguration(array $workflows, ContainerBuilde
508509
if (!isset($config['guard'])) {
509510
continue;
510511
}
512+
513+
if (!class_exists(ExpressionLanguage::class)) {
514+
throw new LogicException('Cannot guard workflows as the ExpressionLanguage component is not installed.');
515+
}
516+
511517
$eventName = sprintf('workflow.%s.guard.%s', $name, $transitionName);
512518
$guard->addTag('kernel.event_listener', array('event' => $eventName, 'method' => 'onTransition'));
513519
$configuration[$eventName] = $config['guard'];

composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,8 @@
6767
"symfony/property-info": "<3.3",
6868
"symfony/serializer": "<3.3",
6969
"symfony/translations": "<3.2",
70-
"symfony/validator": "<3.3"
70+
"symfony/validator": "<3.3",
71+
"symfony/workflow": "<3.3"
7172
},
7273
"suggest": {
7374
"ext-apcu": "For best performance of the system caches",

0 commit comments

Comments
 (0)