From 418dcc39d4a7161e8395589a7861fb7596d3a8e6 Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Fri, 17 Mar 2017 14:38:55 +0100 Subject: [PATCH] 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. --- .../DependencyInjection/FrameworkExtension.php | 6 ++++++ src/Symfony/Bundle/FrameworkBundle/composer.json | 3 ++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php index 2cb32c072e3d1..eff56f0ad0a86 100644 --- a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php +++ b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php @@ -25,6 +25,7 @@ use Symfony\Component\DependencyInjection\Exception\LogicException; use Symfony\Component\DependencyInjection\Reference; use Symfony\Component\DependencyInjection\Loader\XmlFileLoader; +use Symfony\Component\ExpressionLanguage\ExpressionLanguage; use Symfony\Component\Finder\Finder; use Symfony\Component\HttpKernel\DependencyInjection\Extension; use Symfony\Component\Config\FileLocator; @@ -508,6 +509,11 @@ private function registerWorkflowConfiguration(array $workflows, ContainerBuilde if (!isset($config['guard'])) { continue; } + + if (!class_exists(ExpressionLanguage::class)) { + throw new LogicException('Cannot guard workflows as the ExpressionLanguage component is not installed.'); + } + $eventName = sprintf('workflow.%s.guard.%s', $name, $transitionName); $guard->addTag('kernel.event_listener', array('event' => $eventName, 'method' => 'onTransition')); $configuration[$eventName] = $config['guard']; diff --git a/src/Symfony/Bundle/FrameworkBundle/composer.json b/src/Symfony/Bundle/FrameworkBundle/composer.json index ff9a4b96f7d6d..f4f81aece0e69 100644 --- a/src/Symfony/Bundle/FrameworkBundle/composer.json +++ b/src/Symfony/Bundle/FrameworkBundle/composer.json @@ -67,7 +67,8 @@ "symfony/property-info": "<3.3", "symfony/serializer": "<3.3", "symfony/translations": "<3.2", - "symfony/validator": "<3.3" + "symfony/validator": "<3.3", + "symfony/workflow": "<3.3" }, "suggest": { "ext-apcu": "For best performance of the system caches",