8000 bug #25604 Add check for SecurityBundle in createAccessDeniedExceptio… · dunglas/symfony@39f0438 · GitHub
[go: up one dir, main page]

Skip to content

Commit 39f0438

Browse files
author
Robin Chalas
committed
bug symfony#25604 Add check for SecurityBundle in createAccessDeniedException (FGM)
This PR was submitted for the 4.0 branch but it was squashed and merged into the 3.4 branch instead (closes symfony#25604). Discussion ---------- Add check for SecurityBundle in createAccessDeniedException | Q | A | ------------- | --- | Branch? | 4.0 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | symfony#25595 | License | MIT | Doc PR | n.a. Commits ------- a013c01 Add check for SecurityBundle in createAccessDeniedException
10395
2 parents 89903e1 + a013c01 commit 39f0438

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)
0