25 use TYPO3Fluid\Fluid\View\TemplateView;
141 throw new \TYPO3\CMS\Extbase\Mvc\Exception\UnsupportedRequestTypeException(static::class .
' does not support requests of type "' . get_class(
$request) .
'". Supported types are: ' . implode(
' ', $this->supportedRequestTypes), 1187701131);
150 $this->uriBuilder = $this->objectManager->get(\
TYPO3\CMS\
Extbase\Mvc\Web\Routing\UriBuilder::class);
151 $this->uriBuilder->setRequest(
$request);
155 $this->mvcPropertyMappingConfigurationService->initializePropertyMappingConfigurationFromRequest(
$request, $this->arguments);
157 $actionInitializationMethodName =
'initialize' . ucfirst($this->actionMethodName);
158 if (method_exists($this, $actionInitializationMethodName)) {
159 call_user_func([$this, $actionInitializationMethodName]);
164 if ($this->view !==
null) {
188 if (!$this->view instanceof TemplateView) {
195 $pageRenderer = $this->objectManager->get(PageRenderer::class);
197 $headerAssets = $this->view->renderSection(
'HeaderAssets', $variables,
true);
198 $footerAssets = $this->view->renderSection(
'FooterAssets', $variables,
true);
199 if (!empty(trim($headerAssets))) {
200 $pageRenderer->addHeaderData($headerAssets);
202 if (!empty(trim($footerAssets))) {
203 $pageRenderer->addFooterData($footerAssets);
218 $methodParameters = $this->reflectionService
219 ->getClassSchema(static::class)
220 ->getMethod($this->actionMethodName)[
'params'] ?? [];
222 foreach ($methodParameters as $parameterName => $parameterInfo) {
224 if (isset($parameterInfo[
'type'])) {
225 $dataType = $parameterInfo[
'type'];
226 } elseif ($parameterInfo[
'array']) {
229 if ($dataType ===
null) {
230 throw new \TYPO3\CMS\Extbase\Mvc\Exception\InvalidArgumentTypeException(
'The argument type for parameter $' . $parameterName .
' of method ' . static::class .
'->' . $this->actionMethodName .
'() could not be detected.', 1253175643);
232 $defaultValue = $parameterInfo[
'hasDefaultValue'] ===
true ? $parameterInfo[
'defaultValue'] :
null;
233 $this->arguments->addNewArgument($parameterName, $dataType, $parameterInfo[
'optional'] ===
false, $defaultValue);
247 if ($this->arguments->count() === 0) {
251 $classSchema = $this->reflectionService->getClassSchema(static::class);
253 $ignoreValidationAnnotations = array_unique(array_flip(
254 $classSchema->getMethod($this->actionMethodName)[
'tags'][
'ignorevalidation'] ?? []
258 foreach ($this->arguments as $argument) {
259 if (isset($ignoreValidationAnnotations[$argument->getName()])) {
263 $validator = $this->objectManager->get(ConjunctionValidator::class);
264 $validatorDefinitions = $classSchema->getMethod($this->actionMethodName)[
'params'][$argument->getName()][
'validators'] ?? [];
266 foreach ($validatorDefinitions as $validatorDefinition) {
268 $validatorInstance = $this->objectManager->get(
269 $validatorDefinition[
'className'],
270 $validatorDefinition[
'options']
278 $baseValidatorConjunction = $this->validatorResolver->getBaseValidatorConjunction($argument->getDataType());
279 if ($baseValidatorConjunction->count() > 0) {
280 $validator->addValidator($baseValidatorConjunction);
296 throw new \TYPO3\CMS\Extbase\Mvc\Exception\NoSuchActionException(
'An action "' .
$actionMethodName .
'" does not exist in controller "' . static::class .
'".', 1186669086);
310 $preparedArguments = [];
312 foreach ($this->arguments as $argument) {
313 $preparedArguments[] = $argument->getValue();
315 $validationResult = $this->arguments->validate();
316 if (!$validationResult->hasErrors()) {
318 $actionResult = $this->{$this->actionMethodName}(...$preparedArguments);
320 $actionResult = $this->{$this->errorMethodName}();
323 if ($actionResult ===
null && $this->view instanceof ViewInterface) {
324 $this->response->appendContent($this->view->render());
325 } elseif (is_string($actionResult) && $actionResult !==
'') {
326 $this->response->appendContent($actionResult);
327 } elseif (is_object($actionResult) && method_exists($actionResult,
'__toString')) {
328 $this->response->appendContent((
string)$actionResult);
339 $this->signalSlotDispatcher->dispatch(__CLASS__,
'beforeCallActionMethod', [static::class, $this->actionMethodName, $preparedArguments]);
351 if ($viewObjectName !==
false) {
353 $view = $this->objectManager->get($viewObjectName);
359 if (!isset(
$view) && $this->defaultViewObjectName !=
'') {
361 $view = $this->objectManager->get($this->defaultViewObjectName);
369 $view->
assign(
'errorMessage',
'No template was found. View could not be resolved for action "'
370 . $this->request->getControllerActionName() .
'" in class "' . $this->request->getControllerObjectName() .
'"');
373 if (method_exists(
$view,
'injectSettings')) {
374 $view->injectSettings($this->settings);
389 $extbaseFrameworkConfiguration = $this->configurationManager->getConfiguration(
394 $viewFunctionName =
'setTemplateRootPaths';
395 if (method_exists(
$view, $viewFunctionName)) {
396 $setting =
'templateRootPaths';
397 $parameter = $this->
getViewProperty($extbaseFrameworkConfiguration, $setting);
400 $view->$viewFunctionName($parameter);
405 $viewFunctionName =
'setLayoutRootPaths';
406 if (method_exists(
$view, $viewFunctionName)) {
407 $setting =
'layoutRootPaths';
408 $parameter = $this->
getViewProperty($extbaseFrameworkConfiguration, $setting);
411 $view->$viewFunctionName($parameter);
416 $viewFunctionName =
'setPartialRootPaths';
417 if (method_exists(
$view, $viewFunctionName)) {
418 $setting =
'partialRootPaths';
419 $parameter = $this->
getViewProperty($extbaseFrameworkConfiguration, $setting);
422 $view->$viewFunctionName($parameter);
437 protected function getViewProperty($extbaseFrameworkConfiguration, $setting)
441 !empty($extbaseFrameworkConfiguration[
'view'][$setting])
442 && is_array($extbaseFrameworkConfiguration[
'view'][$setting])
444 $values = $extbaseFrameworkConfiguration[
'view'][$setting];
457 $vendorName = $this->request->getControllerVendorName();
458 if ($vendorName ===
null) {
462 $possibleViewName = str_replace(
471 $this->request->getControllerExtensionName(),
472 $this->request->getControllerName(),
473 ucfirst($this->request->getControllerActionName())
475 $this->namespacesViewObjectNamePattern
477 $format = $this->request->getFormat();
478 $viewObjectName = str_replace(
'@format', ucfirst($format), $possibleViewName);
479 if (class_exists($viewObjectName) ===
false) {
480 $viewObjectName = str_replace(
'@format',
'', $possibleViewName);
482 if (isset($this->viewFormatToObjectNameMap[$format]) && class_exists($viewObjectName) ===
false) {
483 $viewObjectName = $this->viewFormatToObjectNameMap[$format];
485 return class_exists($viewObjectName) ? $viewObjectName :
false;
538 if (isset($extbaseSettings[
'persistence'][
'enableAutomaticCacheClearing']) && $extbaseSettings[
'persistence'][
'enableAutomaticCacheClearing'] ===
'1') {
541 $this->cacheService->clearPageCache([$pageUid]);
553 if ($errorFlashMessage !==
false) {
567 return 'An error occurred while trying to call ' . static::class .
'->' . $this->actionMethodName .
'()';
579 $referringRequest = $this->request->getReferringRequest();
580 if ($referringRequest !==
null) {
582 $this->request->setOriginalRequest($originalRequest);
583 $this->request->setOriginalRequestMappingResults($this->arguments->validate());
585 $referringRequest->getControllerActionName(),
586 $referringRequest->getControllerName(),
587 $referringRequest->getControllerExtensionName(),
588 $referringRequest->getArguments()
602 $outputMessage =
'Validation failed while trying to call ' . static::class .
'->' . $this->actionMethodName .
'().' . PHP_EOL;
603 return $outputMessage;
617 'Method ' . __METHOD__ .
' is deprecated and will be removed in TYPO3 v10.0.',
625 $className = get_called_class();
626 $methodNames = get_class_methods($className);
627 foreach ($methodNames as $methodName) {
628 if (strlen($methodName) > 6 && strpos($methodName,
'Action', strlen($methodName) - 6) !==
false) {