/** * 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); }