From 90078827df415ad9a7c462e34739376dcb25bab5 Mon Sep 17 00:00:00 2001 From: "Frederic G. MARAND" Date: Tue, 26 Dec 2017 10:57:46 +0100 Subject: [PATCH 1/3] Issue #25595: AccessDeniedException is not available without the SecurityBundle. --- .../Bundle/FrameworkBundle/Controller/ControllerTrait.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/Symfony/Bundle/FrameworkBundle/Controller/ControllerTrait.php b/src/Symfony/Bundle/FrameworkBundle/Controller/ControllerTrait.php index 96b4fa10fb22a..ef0061e69ec89 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Controller/ControllerTrait.php +++ b/src/Symfony/Bundle/FrameworkBundle/Controller/ControllerTrait.php @@ -289,10 +289,16 @@ protected function createNotFoundException(string $message = 'Not Found', \Excep * * throw $this->createAccessDeniedException('Unable to access this page!'); * + * @throws \LogicException If SecurityBundle is not available + * * @final since version 3.4 */ protected function createAccessDeniedException(string $message = 'Access Denied.', \Exception $previous = null): AccessDeniedException { + if (!class_exists(AccessDeniedException::class)) { + throw new \LogicException('You can not use the "createAccessDeniedException" method if the SecurityBundle is not registered in your application.'); + } + return new AccessDeniedException($message, $previous); } From bf53da1ec11c84b0635d50473871c14a9f3f1a7d Mon Sep 17 00:00:00 2001 From: "Frederic G. MARAND" Date: Tue, 26 Dec 2017 18:00:25 +0100 Subject: [PATCH 2/3] Invite devs to use Flex. --- .../Bundle/FrameworkBundle/Controller/ControllerTrait.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Symfony/Bundle/FrameworkBundle/Controller/ControllerTrait.php b/src/Symfony/Bundle/FrameworkBundle/Controller/ControllerTrait.php index ef0061e69ec89..48f2dec41dddd 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Controller/ControllerTrait.php +++ b/src/Symfony/Bundle/FrameworkBundle/Controller/ControllerTrait.php @@ -296,7 +296,7 @@ protected function createNotFoundException(string $message = 'Not Found', \Excep protected function createAccessDeniedException(string $message = 'Access Denied.', \Exception $previous = null): AccessDeniedException { if (!class_exists(AccessDeniedException::class)) { - throw new \LogicException('You can not use the "createAccessDeniedException" method if the SecurityBundle is not registered in your application.'); + throw new \LogicException('You can not use the "createAccessDeniedException" method if the SecurityBundle is not registered in your application. Try running "composer require security".'); } return new AccessDeniedException($message, $previous); From 6406e57edc061e5ccc131effefe084b686f9f9f7 Mon Sep 17 00:00:00 2001 From: "Frederic G. MARAND" Date: Wed, 27 Dec 2017 21:46:57 +0100 Subject: [PATCH 3/3] Only require security-core, not security. --- .../Bundle/FrameworkBundle/Controller/ControllerTrait.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Symfony/Bundle/FrameworkBundle/Controller/ControllerTrait.php b/src/Symfony/Bundle/FrameworkBundle/Controller/ControllerTrait.php index 48f2dec41dddd..cf7df37e86f94 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Controller/ControllerTrait.php +++ b/src/Symfony/Bundle/FrameworkBundle/Controller/ControllerTrait.php @@ -296,7 +296,7 @@ protected function createNotFoundException(string $message = 'Not Found', \Excep protected function createAccessDeniedException(string $message = 'Access Denied.', \Exception $previous = null): AccessDeniedException { if (!class_exists(AccessDeniedException::class)) { - throw new \LogicException('You can not use the "createAccessDeniedException" method if the SecurityBundle is not registered in your application. Try running "composer require security".'); + throw new \LogicException('You can not use the "createAccessDeniedException" method if the SecurityBundle is not registered in your application. Try running "composer require security-core".'); } return new AccessDeniedException($message, $previous);