Add check for SecurityBundle in createAccessDeniedException

This commit is contained in:
Frederic G. MARAND 2017-12-26 10:57:46 +01:00 committed by Robin Chalas
parent 89903e10f2
commit a013c019a7
1 changed files with 6 additions and 0 deletions

View File

@ -366,10 +366,16 @@ trait ControllerTrait
*
* @return AccessDeniedException
*
* @throws \LogicException If SecurityBundle is not available
*
* @final since version 3.4
*/
protected function createAccessDeniedException($message = 'Access Denied.', \Exception $previous = null)
{
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-core".');
}
return new AccessDeniedException($message, $previous);
}