/** * Sets the value of this argument. * * @param mixed $rawValue The value of this argument * @return \TYPO3\CMS\Extbase\Mvc\Controller\Argument * @throws \TYPO3\CMS\Extbase\Mvc\Exception\InvalidArgumentValueException if the argument is not a valid object of type $dataType */ public function setValue($rawValue) { if ($this->configurationManager->isFeatureEnabled('rewrittenPropertyMapper')) { if ($rawValue === NULL) { $this->value = NULL; return $this; } if (is_object($rawValue) && $rawValue instanceof $this->dataType) { $this->value = $rawValue; return $this; } $this->value = $this->propertyMapper->convert($rawValue, $this->dataType, $this->propertyMappingConfiguration); $this->validationResults = $this->propertyMapper->getMessages(); if ($this->validator !== NULL) { // TODO: Validation API has also changed!!! $validationMessages = $this->validator->validate($this->value); $this->validationResults->merge($validationMessages); } return $this; } else { if ($rawValue === NULL || is_object($rawValue) && $rawValue instanceof $this->dataType) { $this->value = $rawValue; } else { $this->value = $this->transformValue($rawValue); } return $this; } }
/** * Add an CSS class if this view helper has errors * * @return void */ protected function setErrorClassAttribute() { if ($this->hasArgument('class')) { $cssClass = $this->arguments['class'] . ' '; } else { $cssClass = ''; } if ($this->configurationManager->isFeatureEnabled('rewrittenPropertyMapper')) { $mappingResultsForProperty = $this->getMappingResultsForProperty(); if ($mappingResultsForProperty->hasErrors()) { if ($this->hasArgument('errorClass')) { $cssClass .= $this->arguments['errorClass']; } else { $cssClass .= 'error'; } $this->tag->addAttribute('class', $cssClass); } } else { // @deprecated since Fluid 1.4.0, will will be removed two versions after Fluid 6.1. $errors = $this->getErrorsForProperty(); if (count($errors) > 0) { if ($this->hasArgument('errorClass')) { $cssClass .= $this->arguments['errorClass']; } else { $cssClass .= 'error'; } $this->tag->addAttribute('class', $cssClass); } } }
/** * Sets the value of this argument. * * @param mixed $rawValue The value of this argument * @return \TYPO3\CMS\Extbase\Mvc\Controller\Argument * @throws \TYPO3\CMS\Extbase\Property\Exception */ public function setValue($rawValue) { if ($this->configurationManager->isFeatureEnabled('rewrittenPropertyMapper')) { if ($rawValue === NULL) { $this->value = NULL; return $this; } if (is_object($rawValue) && $rawValue instanceof $this->dataType) { $this->value = $rawValue; return $this; } try { $this->value = $this->propertyMapper->convert($rawValue, $this->dataType, $this->propertyMappingConfiguration); } catch (TargetNotFoundException $e) { // for optional arguments no exeption is thrown. if ($this->isRequired()) { throw $e; } } $this->validationResults = $this->propertyMapper->getMessages(); if ($this->validator !== NULL) { // TODO: Validation API has also changed!!! $validationMessages = $this->validator->validate($this->value); $this->validationResults->merge($validationMessages); } return $this; } else { if ($rawValue === NULL || is_object($rawValue) && $rawValue instanceof $this->dataType) { $this->value = $rawValue; } else { $this->value = $this->transformValue($rawValue); } return $this; } }
/** * Handles the web request. The response will automatically be sent to the client. * * @return \TYPO3\CMS\Extbase\Mvc\ResponseInterface|NULL */ public function handleRequest() { $request = $this->requestBuilder->build(); if ($this->extensionService->isActionCacheable(null, null, $request->getControllerName(), $request->getControllerActionName())) { $request->setIsCached(true); } else { $contentObject = $this->configurationManager->getContentObject(); if ($contentObject->getUserObjectType() === \TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer::OBJECTTYPE_USER) { $contentObject->convertToUserIntObject(); // \TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer::convertToUserIntObject() will recreate the object, so we have to stop the request here return null; } $request->setIsCached(false); } if ($this->configurationManager->isFeatureEnabled('requireCHashArgumentForActionArguments')) { $pluginNamespace = $this->extensionService->getPluginNamespace($request->getControllerExtensionName(), $request->getPluginName()); $this->cacheHashEnforcer->enforceForRequest($request, $pluginNamespace); } /** @var $response \TYPO3\CMS\Extbase\Mvc\ResponseInterface */ $response = $this->objectManager->get(\TYPO3\CMS\Extbase\Mvc\Web\Response::class); $this->dispatcher->dispatch($request, $response); return $response; }
/** * Creates an URI used for linking to an Extbase action. * Works in Frontend and Backend mode of TYPO3. * * @param string $actionName Name of the action to be called * @param array $controllerArguments Additional query parameters. Will be "namespaced" and merged with $this->arguments. * @param string $controllerName Name of the target controller. If not set, current ControllerName is used. * @param string $extensionName Name of the target extension, without underscores. If not set, current ExtensionName is used. * @param string $pluginName Name of the target plugin. If not set, current PluginName is used. * @return string the rendered URI * @api * @see build() */ public function uriFor($actionName = NULL, $controllerArguments = array(), $controllerName = NULL, $extensionName = NULL, $pluginName = NULL) { if ($actionName !== NULL) { $controllerArguments['action'] = $actionName; } if ($controllerName !== NULL) { $controllerArguments['controller'] = $controllerName; } else { $controllerArguments['controller'] = $this->request->getControllerName(); } if ($extensionName === NULL) { $extensionName = $this->request->getControllerExtensionName(); } if ($pluginName === NULL && $this->environmentService->isEnvironmentInFrontendMode()) { $pluginName = $this->extensionService->getPluginNameByAction($extensionName, $controllerArguments['controller'], $controllerArguments['action']); } if ($pluginName === NULL) { $pluginName = $this->request->getPluginName(); } $this->disableCacheHashForNonCacheableAction($controllerArguments); if ($this->environmentService->isEnvironmentInFrontendMode() && $this->configurationManager->isFeatureEnabled('skipDefaultArguments')) { $controllerArguments = $this->removeDefaultControllerAndAction($controllerArguments, $extensionName, $pluginName); } if ($this->targetPageUid === NULL && $this->environmentService->isEnvironmentInFrontendMode()) { $this->targetPageUid = $this->extensionService->getTargetPidByPlugin($extensionName, $pluginName); } if ($this->format !== '') { $controllerArguments['format'] = $this->format; } if ($this->argumentPrefix !== NULL) { $prefixedControllerArguments = array($this->argumentPrefix => $controllerArguments); } else { $pluginNamespace = $this->extensionService->getPluginNamespace($extensionName, $pluginName); $prefixedControllerArguments = array($pluginNamespace => $controllerArguments); } ArrayUtility::mergeRecursiveWithOverrule($this->arguments, $prefixedControllerArguments); return $this->build(); }
/** * Maps arguments delivered by the request object to the local controller arguments. * * @throws Exception\RequiredArgumentMissingException * @return void */ protected function mapRequestArgumentsToControllerArguments() { if ($this->configurationManager->isFeatureEnabled('rewrittenPropertyMapper')) { foreach ($this->arguments as $argument) { $argumentName = $argument->getName(); if ($this->request->hasArgument($argumentName)) { $argument->setValue($this->request->getArgument($argumentName)); } elseif ($argument->isRequired()) { throw new \TYPO3\CMS\Extbase\Mvc\Controller\Exception\RequiredArgumentMissingException('Required argument "' . $argumentName . '" is not set for ' . $this->request->getControllerObjectName() . '->' . $this->request->getControllerActionName() . '.', 1298012500); } } } else { // @deprecated since Extbase 1.4, will be removed two versions after Extbase 6.1 $optionalPropertyNames = array(); $allPropertyNames = $this->arguments->getArgumentNames(); foreach ($allPropertyNames as $propertyName) { if ($this->arguments[$propertyName]->isRequired() === FALSE) { $optionalPropertyNames[] = $propertyName; } } /** @var $validator ArgumentsValidator */ $validator = $this->objectManager->get('TYPO3\\CMS\\Extbase\\Mvc\\Controller\\ArgumentsValidator'); $this->deprecatedPropertyMapper->mapAndValidate($allPropertyNames, $this->request->getArguments(), $this->arguments, $optionalPropertyNames, $validator); $this->argumentsMappingResults = $this->deprecatedPropertyMapper->getMappingResults(); } }
/** * Renders hidden form fields for referrer information about * the current controller and action. * * @return string Hidden fields with referrer information * @todo filter out referrer information that is equal to the target (e.g. same packageKey) */ protected function renderHiddenReferrerFields() { $request = $this->controllerContext->getRequest(); $extensionName = $request->getControllerExtensionName(); $vendorName = $request->getControllerVendorName(); $controllerName = $request->getControllerName(); $actionName = $request->getControllerActionName(); $result = chr(10); if ($this->configurationManager->isFeatureEnabled('rewrittenPropertyMapper')) { $result .= '<input type="hidden" name="' . $this->prefixFieldName('__referrer[@extension]') . '" value="' . $extensionName . '" />' . chr(10); if ($vendorName !== NULL) { $result .= '<input type="hidden" name="' . $this->prefixFieldName('__referrer[@vendor]') . '" value="' . $vendorName . '" />' . chr(10); } $result .= '<input type="hidden" name="' . $this->prefixFieldName('__referrer[@controller]') . '" value="' . $controllerName . '" />' . chr(10); $result .= '<input type="hidden" name="' . $this->prefixFieldName('__referrer[@action]') . '" value="' . $actionName . '" />' . chr(10); $result .= '<input type="hidden" name="' . $this->prefixFieldName('__referrer[arguments]') . '" value="' . htmlspecialchars($this->hashService->appendHmac(base64_encode(serialize($request->getArguments())))) . '" />' . chr(10); } else { // @deprecated since Fluid 1.4.0, will be removed two versions after Fluid 6.1. $result .= '<input type="hidden" name="' . $this->prefixFieldName('__referrer[extensionName]') . '" value="' . $extensionName . '" />' . chr(10); $result .= '<input type="hidden" name="' . $this->prefixFieldName('__referrer[controllerName]') . '" value="' . $controllerName . '" />' . chr(10); $result .= '<input type="hidden" name="' . $this->prefixFieldName('__referrer[actionName]') . '" value="' . $actionName . '" />' . chr(10); } return $result; }