methodNotSupported() public static method

Is thrown when request method (e.g. POST or PUT) is not allowed for this resource
public static methodNotSupported ( string $message = '', Exception | Throwable $previous = NULL ) : BadRequestException
$message string
$previous Exception | Throwable
return BadRequestException
示例#1
0
 public function startup()
 {
     try {
         $id = $this->getParameter('id');
         if ($id !== NULL && ($id = $this->isValidId($id)) === FALSE) {
             throw BadRequestException::methodNotSupported('Url must follow convention /presenter/id/relation/relationId.' . ' Valid ID is only positive, non zero integer.');
         }
         $action = $this->getAction();
         if ($action === 'create' && $id) {
             $this->changeAction('update');
         }
         parent::startup();
         if (strpos($action, 'read') === FALSE) {
             $this->inputData = $this->inputData ?: $this->getInputData();
         }
         if (($relation = $this->getParameter('relation')) !== NULL) {
             $this->table = $this->db->table($relation)->where($this->getTableName(), $id);
             $this->deepListing = $this->queryFilter = NULL;
         } else {
             $this->table = $this->db->table($this->getTableName());
         }
     } catch (BadRequestException $ex) {
         $this->sendErrorResource($ex);
     }
 }
示例#2
0
 /**
  * Check allowed methods
  *
  * @throws BadRequestException If method is not supported but another one can be used
  */
 protected function checkAllowedMethods()
 {
     $availableMethods = $this->methods->getOptions($this->request->getUrl());
     if (!$availableMethods || in_array($this->request->method, $availableMethods)) {
         return;
     }
     $allow = implode(', ', $availableMethods);
     $this->response->setHeader('Allow', $allow);
     throw BadRequestException::methodNotSupported('Method not supported. Available methods: ' . $allow);
 }
示例#3
0
 public function actionDelete($id)
 {
     $e = BadRequestException::methodNotSupported('Currently not supported');
     $this->sendErrorResource($e);
 }
示例#4
0
 public function actionDelete($id)
 {
     $e = BadRequestException::methodNotSupported('Tap cannot be deleted');
     $this->sendErrorResource($e);
 }
示例#5
0
 public function actionUpdate($id)
 {
     $message = 'Keg can be modified only in relation to tap';
     $exception = BadRequestException::methodNotSupported($message);
     $this->sendErrorResource($exception);
 }