protected resolveActionMethodName ( ) : string | ||
return | string | Method name of the current action |
protected function resolveActionMethodName()
{
$actionMethodName = $this->request->getControllerActionName() . 'Action';
if (!is_callable([$this, $actionMethodName])) {
throw new NoSuchActionException(sprintf('An action "%s" does not exist in controller "%s".', $actionMethodName, get_class($this)), 1186669086);
}
$publicActionMethods = static::getPublicActionMethods($this->objectManager);
if (!isset($publicActionMethods[$actionMethodName])) {
throw new InvalidActionVisibilityException(sprintf('The action "%s" in controller "%s" is not public!', $actionMethodName, get_class($this)), 1186669086);
}
return $actionMethodName;
}
/** * Determines the action method and assures that the method exists. * * @return string The action method name * @throws NoSuchActionException if the action specified in the request object does not exist (and if there's no default action either). */ protected function resolveActionMethodName() { if ($this->request->getControllerActionName() === 'index') { $actionName = 'index'; switch ($this->request->getHttpRequest()->getMethod()) { case 'HEAD': case 'GET': $actionName = $this->request->hasArgument($this->resourceArgumentName) ? 'show' : 'list'; break; case 'POST': $actionName = 'create'; break; case 'PUT': if (!$this->request->hasArgument($this->resourceArgumentName)) { $this->throwStatus(400, null, 'No resource specified'); } $actionName = 'update'; break; case 'DELETE': if (!$this->request->hasArgument($this->resourceArgumentName)) { $this->throwStatus(400, null, 'No resource specified'); } $actionName = 'delete'; break; } $this->request->setControllerActionName($actionName); } return parent::resolveActionMethodName(); }