public function render($action = null, $controller = null, $extensionName = null, $pluginName = null, $vendorName = null, array $arguments = [])
{
$contentObjectBackup = $this->configurationManager->getContentObject();
if (true === isset($this->request)) {
$configurationBackup = $this->configurationManager->getConfiguration(ConfigurationManagerInterface::CONFIGURATION_TYPE_FRAMEWORK, $this->request->getControllerExtensionName(), $this->request->getPluginName());
}
$temporaryContentObject = new ContentObjectRenderer();
/** @var \TYPO3\CMS\Extbase\Mvc\Web\Request $request */
$request = $this->objectManager->get($this->requestType);
$request->setControllerActionName($action);
$request->setControllerName($controller);
$request->setPluginName($pluginName);
$request->setControllerExtensionName($extensionName);
$request->setArguments($arguments);
// TODO: remove for 6.2 LTS
if (false === empty($vendorName)) {
$request->setControllerVendorName($vendorName);
}
try {
/** @var \TYPO3\CMS\Extbase\Mvc\ResponseInterface $response */
$response = $this->objectManager->get($this->responseType);
$this->configurationManager->setContentObject($temporaryContentObject);
$this->configurationManager->setConfiguration($this->configurationManager->getConfiguration(ConfigurationManagerInterface::CONFIGURATION_TYPE_FRAMEWORK, $extensionName, $pluginName));
$this->dispatcher->dispatch($request, $response);
$this->configurationManager->setContentObject($contentObjectBackup);
if (true === isset($configurationBackup)) {
$this->configurationManager->setConfiguration($configurationBackup);
}
return $response;
} catch (\Exception $error) {
if (false === (bool) $this->arguments['graceful']) {
throw $error;
}
if (false === empty($this->arguments['onError'])) {
return sprintf($this->arguments['onError'], [$error->getMessage()], $error->getCode());
}
return $error->getMessage() . ' (' . $error->getCode() . ')';
}
}