/** * Redirects the request to another action and / or controller. * * Redirect will be sent to the client which then performs another request to the new URI. * * NOTE: This method only supports web requests and will thrown an exception * if used with other request types. * * @param string $actionName Name of the action to forward to * @param string $controllerName Unqualified object name of the controller to forward to. If not specified, the current controller is used. * @param string $extensionName Name of the extension containing the controller to forward to. If not specified, the current extension is assumed. * @param array $arguments Arguments to pass to the target action * @param integer $pageUid Target page uid. If NULL, the current page uid is used * @param integer $delay (optional) The delay in seconds. Default is no delay. * @param integer $statusCode (optional) The HTTP status code for the redirect. Default is "303 See Other * @return void * @throws \TYPO3\CMS\Extbase\Mvc\Exception\UnsupportedRequestTypeException If the request is not a web request * @throws \TYPO3\CMS\Extbase\Mvc\Exception\StopActionException * @see forward() * @api */ protected function redirect($actionName, $controllerName = NULL, $extensionName = NULL, array $arguments = NULL, $pageUid = NULL, $delay = 0, $statusCode = 303) { if (!$this->request instanceof \TYPO3\CMS\Extbase\Mvc\Web\Request) { throw new \TYPO3\CMS\Extbase\Mvc\Exception\UnsupportedRequestTypeException('redirect() only supports web requests.', 1220539734); } if ($controllerName === NULL) { $controllerName = $this->request->getControllerName(); } $this->uriBuilder->reset()->setTargetPageUid($pageUid)->setCreateAbsoluteUri(TRUE); if (\TYPO3\CMS\Core\Utility\GeneralUtility::getIndpEnv('TYPO3_SSL')) { $this->uriBuilder->setAbsoluteUriScheme('https'); } $uri = $this->uriBuilder->uriFor($actionName, $arguments, $controllerName, $extensionName); $this->redirectToUri($uri, $delay, $statusCode); }
/** * 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(); }
/** * Determines the fully qualified view object name. * * @return mixed The fully qualified view object name or FALSE if no matching view could be found. * @api */ protected function resolveViewObjectName() { $vendorName = $this->request->getControllerVendorName(); if ($vendorName === null) { return false; } $possibleViewName = str_replace(['@vendor', '@extension', '@controller', '@action'], [$vendorName, $this->request->getControllerExtensionName(), $this->request->getControllerName(), ucfirst($this->request->getControllerActionName())], $this->namespacesViewObjectNamePattern); $format = $this->request->getFormat(); $viewObjectName = str_replace('@format', ucfirst($format), $possibleViewName); if (class_exists($viewObjectName) === false) { $viewObjectName = str_replace('@format', '', $possibleViewName); } if (isset($this->viewFormatToObjectNameMap[$format]) && class_exists($viewObjectName) === false) { $viewObjectName = $this->viewFormatToObjectNameMap[$format]; } return class_exists($viewObjectName) ? $viewObjectName : false; }
/** * Determines the fully qualified view object name. * * @return mixed The fully qualified view object name or FALSE if no matching view could be found. * @api */ protected function resolveViewObjectName() { $vendorName = $this->request->getControllerVendorName(); if ($vendorName !== NULL) { $possibleViewName = str_replace('@vendor', $vendorName, $this->namespacesViewObjectNamePattern); } else { $possibleViewName = $this->viewObjectNamePattern; } $possibleViewName = str_replace(array('@extension', '@controller', '@action'), array($this->request->getControllerExtensionName(), $this->request->getControllerName(), ucfirst($this->request->getControllerActionName())), $possibleViewName); $format = $this->request->getFormat(); $viewObjectName = str_replace('@format', ucfirst($format), $possibleViewName); if (class_exists($viewObjectName) === FALSE) { $viewObjectName = str_replace('@format', '', $possibleViewName); } if (isset($this->viewFormatToObjectNameMap[$format]) && class_exists($viewObjectName) === FALSE) { $viewObjectName = $this->viewFormatToObjectNameMap[$format]; } return class_exists($viewObjectName) ? $viewObjectName : FALSE; }
/** * Gets a localized error message * * @return string */ public function getErrorFlashMessage() { $controllerName = strtolower($this->request->getControllerName()); $actionName = strtolower($this->request->getControllerActionName()); return $this->translate('error.' . $controllerName . '.' . $actionName . '.' . $this->accessError, 't3events_reservation'); }