unknownActionClass() public static method

public static unknownActionClass ( string $class ) : DrestException
$class string
return DrestException
Example #1
0
 /**
  * Gets an instance of the "default" action based of request information
  * @throws DrestException
  * @return AbstractAction $action
  */
 protected function getDefaultAction()
 {
     $httpMethod = $this->dm->calledWithANamedRoute() ? array_slice($this->matched_route->getVerbs(), 0, 1)[0] : $this->getRequest()->getHttpMethod();
     $className = '\\Drest\\Service\\Action\\' . ucfirst(strtolower($httpMethod));
     switch ($httpMethod) {
         case Request::METHOD_GET:
         case Request::METHOD_DELETE:
             $className .= $this->matched_route->isCollection() ? 'Collection' : 'Element';
             break;
         default:
             $className .= 'Element';
             break;
     }
     if (!class_exists($className)) {
         throw DrestException::unknownActionClass($className);
     }
     return new $className($this);
 }