Browse Source

refactor ErrorHandler

Olivier Massot 1 year ago
parent
commit
8b90b16c65
1 changed files with 16 additions and 20 deletions
  1. 16 20
      ot_templating/Classes/Page/ErrorHandler.php

+ 16 - 20
ot_templating/Classes/Page/ErrorHandler.php

@@ -12,13 +12,10 @@ use TYPO3\CMS\Core\Error\PageErrorHandler\PageContentErrorHandler;
 use TYPO3\CMS\Core\Error\PageErrorHandler\PageErrorHandlerInterface;
 use TYPO3\CMS\Core\Http\HtmlResponse;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
-use TYPO3\CMS\Extbase\Mvc\Controller\ControllerContext;
 use TYPO3\CMS\Extbase\Mvc\Request;
-use TYPO3\CMS\Extbase\Mvc\View\ViewInterface;
-use TYPO3\CMS\Extbase\Mvc\Web\Routing\UriBuilder;
-use TYPO3\CMS\Extbase\Object\ObjectManager;
 use TYPO3\CMS\Fluid\Core\Rendering\RenderingContext;
 use TYPO3\CMS\Fluid\View\TemplateView;
+use TYPO3Fluid\Fluid\View\ViewInterface;
 
 class ErrorHandler implements PageErrorHandlerInterface
 {
@@ -62,6 +59,20 @@ class ErrorHandler implements PageErrorHandlerInterface
         $this->errorHandlerConfiguration = $configuration;
 
         $this->view = GeneralUtility::makeInstance(TemplateView::class);
+
+        $this->otWebsiteRepository = GeneralUtility::makeInstance(OtWebsiteRepository::class);
+        $this->otPageRepository = GeneralUtility::makeInstance(OtPageRepository::class);
+
+        $connectionPool = GeneralUtility::makeInstance(ConnectionPool::class);
+        $this->otWebsiteRepository->injectConnectionPool($connectionPool);
+
+        $pageRepository = GeneralUtility::makeInstance(PageRepository::class);
+        $this->otPageRepository->injectPageRepository($pageRepository);
+        $this->otPageRepository->injectConnectionPool($connectionPool);
+
+        $this->request = GeneralUtility::makeInstance(Request::class);
+
+        $this->renderingContext = GeneralUtility::makeInstance(RenderingContext::class);
     }
 
     /**
@@ -107,22 +118,7 @@ class ErrorHandler implements PageErrorHandlerInterface
         string $message,
         array $reasons = []
     ): ResponseInterface {
-
-        $this->otWebsiteRepository = GeneralUtility::makeInstance(OtWebsiteRepository::class);
-        $this->otPageRepository = GeneralUtility::makeInstance(OtPageRepository::class);
-
-        $connectionPool = GeneralUtility::makeInstance(ConnectionPool::class);
-        $this->otWebsiteRepository->injectConnectionPool($connectionPool);
-
-        $pageRepository = GeneralUtility::makeInstance(PageRepository::class);
-        $this->otPageRepository->injectPageRepository($pageRepository);
-        $this->otPageRepository->injectConnectionPool($connectionPool);
-
-        $this->request = GeneralUtility::makeInstance(Request::class);
-
-        $this->renderingContext = GeneralUtility::makeInstance(RenderingContext::class);
-
-//        $this->request->setControllerExtensionName('ot_templating');
+        $this->request->setControllerExtensionName('ot_templating');
         $this->renderingContext->setRequest($this->request);
 
         $this->view->setRenderingContext($this->renderingContext);