vendor/symfony/security-core/Exception/AccessDeniedException.php line 22

  1. <?php
  2. /*
  3.  * This file is part of the Symfony package.
  4.  *
  5.  * (c) Fabien Potencier <fabien@symfony.com>
  6.  *
  7.  * For the full copyright and license information, please view the LICENSE
  8.  * file that was distributed with this source code.
  9.  */
  10. namespace Symfony\Component\Security\Core\Exception;
  11. use Symfony\Component\HttpKernel\Attribute\WithHttpStatus;
  12. /**
  13.  * AccessDeniedException is thrown when the account has not the required role.
  14.  *
  15.  * @author Fabien Potencier <fabien@symfony.com>
  16.  */
  17. #[WithHttpStatus(403)]
  18. class AccessDeniedException extends RuntimeException
  19. {
  20.     private array $attributes = [];
  21.     private mixed $subject null;
  22.     public function __construct(string $message 'Access Denied.'\Throwable $previous nullint $code 403)
  23.     {
  24.         parent::__construct($message$code$previous);
  25.     }
  26.     public function getAttributes(): array
  27.     {
  28.         return $this->attributes;
  29.     }
  30.     /**
  31.      * @return void
  32.      */
  33.     public function setAttributes(array|string $attributes)
  34.     {
  35.         $this->attributes = (array) $attributes;
  36.     }
  37.     public function getSubject(): mixed
  38.     {
  39.         return $this->subject;
  40.     }
  41.     /**
  42.      * @return void
  43.      */
  44.     public function setSubject(mixed $subject)
  45.     {
  46.         $this->subject $subject;
  47.     }
  48. }