/**
  * Determines the action method and assures that the method exists.
  *
  * @return string The action method name
  * @throws \F3\FLOW3\MVC\Exception\NoSuchActionException if the action specified in the request object does not exist (and if there's no default action either).
  * @author Robert Lemke <*****@*****.**>
  */
 protected function resolveActionMethodName()
 {
     if ($this->request->getControllerActionName() === 'index') {
         $actionName = 'index';
         switch ($this->request->getMethod()) {
             case 'GET':
                 $actionName = $this->request->hasArgument('id') ? 'show' : 'list';
                 break;
             case 'POST':
                 $actionName = 'create';
                 break;
             case 'PUT':
                 if (!$this->request->hasArgument('id')) {
                     $this->throwStatus(400, NULL, 'Missing identifier');
                 }
                 $actionName = 'update';
                 break;
             case 'DELETE':
                 if (!$this->request->hasArgument('id')) {
                     $this->throwStatus(400, NULL, 'Missing identifier');
                 }
                 $actionName = 'delete';
                 break;
         }
         $this->request->setControllerActionName($actionName);
     }
     return parent::resolveActionMethodName();
 }
예제 #2
0
 /**
  * Sets package key, subpackage key, controller name, action name and format
  * of the current request.
  *
  * @param array $arguments
  * @return void
  * @author Bastian Waidelich <*****@*****.**>
  * @author Karsten Dambekalns <*****@*****.**>
  * @see \F3\FLOW3\MVC\Web\Request
  * @api
  */
 protected function setControllerKeysAndFormat(array $arguments)
 {
     foreach ($arguments as $argumentName => $argumentValue) {
         switch ($argumentName) {
             case '@package':
                 $this->request->setControllerPackageKey($argumentValue);
                 break;
             case '@subpackage':
                 $this->request->setControllerSubpackageKey($argumentValue);
                 break;
             case '@controller':
                 $this->request->setControllerName($argumentValue);
                 break;
             case '@action':
                 $this->request->setControllerActionName(lcfirst($argumentValue));
                 break;
             case '@format':
                 $this->request->setFormat(strtolower($argumentValue));
                 break;
         }
     }
 }