|
@@ -9,9 +9,12 @@ use TYPO3\CMS\Core\Error\PageErrorHandler\PageContentErrorHandler;
|
|
|
use TYPO3\CMS\Core\Error\PageErrorHandler\PageErrorHandlerInterface;
|
|
use TYPO3\CMS\Core\Error\PageErrorHandler\PageErrorHandlerInterface;
|
|
|
use TYPO3\CMS\Core\Http\HtmlResponse;
|
|
use TYPO3\CMS\Core\Http\HtmlResponse;
|
|
|
use TYPO3\CMS\Core\Utility\GeneralUtility;
|
|
use TYPO3\CMS\Core\Utility\GeneralUtility;
|
|
|
|
|
+use TYPO3\CMS\Extbase\Mvc\Controller\ControllerContext;
|
|
|
|
|
+use TYPO3\CMS\Extbase\Mvc\View\ViewInterface;
|
|
|
|
|
+use TYPO3\CMS\Extbase\Mvc\Web\Routing\UriBuilder;
|
|
|
use TYPO3\CMS\Extbase\Object\ObjectManager;
|
|
use TYPO3\CMS\Extbase\Object\ObjectManager;
|
|
|
|
|
+use TYPO3\CMS\Fluid\Core\Rendering\RenderingContext;
|
|
|
use TYPO3\CMS\Fluid\View\TemplateView;
|
|
use TYPO3\CMS\Fluid\View\TemplateView;
|
|
|
-use TYPO3Fluid\Fluid\View\ViewInterface;
|
|
|
|
|
|
|
|
|
|
class ErrorHandler implements PageErrorHandlerInterface
|
|
class ErrorHandler implements PageErrorHandlerInterface
|
|
|
{
|
|
{
|
|
@@ -50,6 +53,16 @@ class ErrorHandler implements PageErrorHandlerInterface
|
|
|
$this->errorHandlerConfiguration = $configuration;
|
|
$this->errorHandlerConfiguration = $configuration;
|
|
|
|
|
|
|
|
$this->view = GeneralUtility::makeInstance(TemplateView::class);
|
|
$this->view = GeneralUtility::makeInstance(TemplateView::class);
|
|
|
|
|
+
|
|
|
|
|
+ $objectManager = GeneralUtility::makeInstance(ObjectManager::class);
|
|
|
|
|
+ $controllerContext = $objectManager->get(ControllerContext::class);
|
|
|
|
|
+ $renderingContext = $objectManager->get(RenderingContext::class);
|
|
|
|
|
+ $webRequest = $objectManager->get(\TYPO3\CMS\Extbase\Mvc\Request::class);
|
|
|
|
|
+ $webRequest->setControllerExtensionName('ot_templating');
|
|
|
|
|
+ $controllerContext->setRequest($webRequest);
|
|
|
|
|
+ $renderingContext->setControllerContext($controllerContext);
|
|
|
|
|
+
|
|
|
|
|
+ $this->view->setRenderingContext($renderingContext);
|
|
|
$this->view->setTemplateRootPaths([self::TEMPLATES_ROOT_PATHS]);
|
|
$this->view->setTemplateRootPaths([self::TEMPLATES_ROOT_PATHS]);
|
|
|
$this->view->setLayoutRootPaths([self::LAYOUTS_ROOT_PATHS]);
|
|
$this->view->setLayoutRootPaths([self::LAYOUTS_ROOT_PATHS]);
|
|
|
$this->view->setPartialRootPaths([self::PARTIALS_ROOT_PATHS]);
|
|
$this->view->setPartialRootPaths([self::PARTIALS_ROOT_PATHS]);
|
|
@@ -71,9 +84,9 @@ class ErrorHandler implements PageErrorHandlerInterface
|
|
|
): ResponseInterface {
|
|
): ResponseInterface {
|
|
|
|
|
|
|
|
$homeUri = "https://opentalent.fr";
|
|
$homeUri = "https://opentalent.fr";
|
|
|
- $title = 'Page introuvable';
|
|
|
|
|
|
|
+ $title = 'Page Introuvable';
|
|
|
|
|
|
|
|
- // This variable role is to prevent redirection loop,
|
|
|
|
|
|
|
+ // This variable aims to prevent redirection loop
|
|
|
$isCircular = preg_match('/.*\/page-introuvable/', $request->getUri()->getPath());
|
|
$isCircular = preg_match('/.*\/page-introuvable/', $request->getUri()->getPath());
|
|
|
|
|
|
|
|
$pageRepository = GeneralUtility::makeInstance(ObjectManager::class)->get(OtPageRepository::class);
|
|
$pageRepository = GeneralUtility::makeInstance(ObjectManager::class)->get(OtPageRepository::class);
|
|
@@ -90,7 +103,7 @@ class ErrorHandler implements PageErrorHandlerInterface
|
|
|
|
|
|
|
|
$subPages = $pageRepository->getAllSubpagesForPage($rootUid, true);
|
|
$subPages = $pageRepository->getAllSubpagesForPage($rootUid, true);
|
|
|
foreach ($subPages as $page) {
|
|
foreach ($subPages as $page) {
|
|
|
- if ($page['slug'] == '/page-introuvable') {
|
|
|
|
|
|
|
+ if ($page['tx_fed_page_controller_action'] == 'OpenTalent.OtTemplating->error/404') {
|
|
|
|
|
|
|
|
$errorHandler = GeneralUtility::makeInstance(
|
|
$errorHandler = GeneralUtility::makeInstance(
|
|
|
PageContentErrorHandler::class,
|
|
PageContentErrorHandler::class,
|
|
@@ -104,7 +117,7 @@ class ErrorHandler implements PageErrorHandlerInterface
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
} else {
|
|
} else {
|
|
|
- $title = "Page inexistante";
|
|
|
|
|
|
|
+ $title = 'Page Introuvable';
|
|
|
$homeUri = self::REDIRECT_FALLBACK;
|
|
$homeUri = self::REDIRECT_FALLBACK;
|
|
|
}
|
|
}
|
|
|
|
|
|