/** * Calls the specified action method and passes the arguments. * * If the action returns a string, it is appended to the content in the * response object. If the action doesn't return anything and a valid * view exists, the view is rendered automatically. * * @return void */ protected function callActionMethod() { $preparedArguments = []; foreach ($this->arguments as $argument) { $preparedArguments[] = $argument->getValue(); } $validationResult = $this->arguments->getValidationResults(); if (!$validationResult->hasErrors()) { $actionResult = call_user_func_array([$this, $this->actionMethodName], $preparedArguments); } else { $actionIgnoredArguments = static::getActionIgnoredValidationArguments($this->objectManager); if (isset($actionIgnoredArguments[$this->actionMethodName])) { $ignoredArguments = $actionIgnoredArguments[$this->actionMethodName]; } else { $ignoredArguments = []; } // if there exists more errors than in ignoreValidationAnnotations => call error method // else => call action method $shouldCallActionMethod = true; /** @var Result $subValidationResult */ foreach ($validationResult->getSubResults() as $argumentName => $subValidationResult) { if (!$subValidationResult->hasErrors()) { continue; } if (isset($ignoredArguments[$argumentName]) && $subValidationResult->getErrors(TargetNotFoundError::class) === []) { continue; } $shouldCallActionMethod = false; break; } if ($shouldCallActionMethod) { $actionResult = call_user_func_array([$this, $this->actionMethodName], $preparedArguments); } else { $actionResult = call_user_func([$this, $this->errorMethodName]); } } if ($actionResult === null && $this->view instanceof ViewInterface) { $this->response->appendContent($this->view->render()); } elseif (is_string($actionResult) && strlen($actionResult) > 0) { $this->response->appendContent($actionResult); } elseif (is_object($actionResult) && method_exists($actionResult, '__toString')) { $this->response->appendContent((string) $actionResult); } }
/** * Initialize and render the fallback view * * @return string */ public function renderFallbackView() { $this->fallbackView->setControllerContext($this->controllerContext); $this->fallbackView->assignMultiple($this->variables); return $this->fallbackView->render(); }