Skip to content

Commit a013c01

Browse files
fgmRobin Chalas
authored andcommitted
Add check for SecurityBundle in createAccessDeniedException
1 parent 89903e1 commit a013c01

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/Symfony/Bundle/FrameworkBundle/Controller/ControllerTrait.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -366,10 +366,16 @@ protected function createNotFoundException($message = 'Not Found', \Exception $p
366366
*
367367
* @return AccessDeniedException
368368
*
369+
* @throws \LogicException If SecurityBundle is not available
370+
*
369371
* @final since version 3.4
370372
*/
371373
protected function createAccessDeniedException($message = 'Access Denied.', \Exception $previous = null)
372374
{
375+
if (!class_exists(AccessDeniedException::class)) {
376+
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".');
377+
}
378+
373379
return new AccessDeniedException($message, $previous);
374380
}
375381

0 commit comments

Comments
 (0)