forbidden() public static method

Is thrown when access to this resource is forbidden
public static forbidden ( string $message = '', Exception | Throwable $previous = NULL ) : BadRequestException
$message string
$previous Exception | Throwable
return BadRequestException
Example #1
0
 public function startup()
 {
     if ($this->getAction() !== 'read') {
         throw BadRequestException::forbidden('Stat presenter handles GET requests ONLY.');
     }
     ResourcePresenter::startup();
     $this->series = $this->getParameter('series');
     $this->data = $this->getParameter('data');
     $this->dateBegin = $this->getParameter('dateBegin');
     $this->dateEnd = $this->getParameter('dateEnd');
 }
Example #2
0
 public function validateCreateCredit()
 {
     if (!$this->getUser()->isInRole('beer_manager')) {
         throw BadRequestException::forbidden('Only beer manager can add credit to user');
     }
 }