Преглед изворни кода

remove usage of deprecated ObjectManager

Olivier Massot пре 1 година
родитељ
комит
3702eb4b28
37 измењених фајлова са 405 додато и 301 уклоњено
  1. 7 2
      ot_admin/Classes/Command/AddRedirectionCommand.php
  2. 10 6
      ot_admin/Classes/Command/ClearObsoleteWebsitesSiteCommand.php
  3. 6 3
      ot_admin/Classes/Command/ClearSiteCacheCommand.php
  4. 7 2
      ot_admin/Classes/Command/CreateSiteCommand.php
  5. 6 3
      ot_admin/Classes/Command/DeleteSiteCommand.php
  6. 7 2
      ot_admin/Classes/Command/GetSiteStatusCommand.php
  7. 7 2
      ot_admin/Classes/Command/RegenConfigFilesCommand.php
  8. 7 2
      ot_admin/Classes/Command/RemoveRedirectionCommand.php
  9. 10 6
      ot_admin/Classes/Command/ResetBeUserPermsCommand.php
  10. 8 3
      ot_admin/Classes/Command/ScanCommand.php
  11. 7 2
      ot_admin/Classes/Command/SetSiteDomainCommand.php
  12. 8 5
      ot_admin/Classes/Command/UndeleteSiteCommand.php
  13. 10 6
      ot_admin/Classes/Command/UpdateSiteCommand.php
  14. 10 5
      ot_admin/Classes/Controller/ScanController.php
  15. 13 4
      ot_admin/Classes/Controller/SiteController.php
  16. 17 26
      ot_admin/Classes/Http/ApiController.php
  17. 12 11
      ot_core/Classes/Cache/OtCacheManager.php
  18. 2 4
      ot_core/Classes/Controller/SelectedSiteController.php
  19. 12 3
      ot_optimizer/Classes/Middleware/Frontend/OtPageResolver.php
  20. 6 6
      ot_stats/Classes/Controller/OtStatsController.php
  21. 7 7
      ot_stats/Classes/Domain/Repository/MatomoWebsiteRepository.php
  22. 4 3
      ot_stats/Classes/Middleware/RequestHandler.php
  23. 8 10
      ot_stats/Classes/ViewHelpers/MatomoSiteIdViewHelper.php
  24. 9 14
      ot_templating/Classes/Controller/OtCustomizerController.php
  25. 6 2
      ot_templating/Classes/News/NewsFilter.php
  26. 65 26
      ot_templating/Classes/Page/ErrorHandler.php
  27. 13 15
      ot_templating/Classes/ViewHelpers/EventsPage/GetIdViewHelper.php
  28. 12 16
      ot_templating/Classes/ViewHelpers/GetPageUidViewHelper.php
  29. 9 14
      ot_templating/Classes/ViewHelpers/NewsPage/GetIdViewHelper.php
  30. 10 15
      ot_templating/Classes/ViewHelpers/Page/GetFirstWithTemplateViewHelper.php
  31. 9 11
      ot_templating/Classes/ViewHelpers/Request/GetWebsiteViewHelper.php
  32. 9 10
      ot_templating/Classes/ViewHelpers/RootPage/GetIdViewHelper.php
  33. 11 10
      ot_templating/Classes/ViewHelpers/RootPage/GetUriViewHelper.php
  34. 11 12
      ot_templating/Classes/ViewHelpers/Template/CurrentViewHelper.php
  35. 13 15
      ot_templating/Classes/ViewHelpers/Template/GetPreferenceViewHelper.php
  36. 13 14
      ot_templating/Classes/ViewHelpers/Template/GetPreferencesViewHelper.php
  37. 24 4
      ot_templating/Classes/XClass/Form/Configuration/ConfigurationManager.php

+ 7 - 2
ot_admin/Classes/Command/AddRedirectionCommand.php

@@ -20,6 +20,12 @@ use TYPO3\CMS\Extbase\Object\ObjectManager;
  */
 class AddRedirectionCommand extends Command
 {
+    public function __construct(
+        private readonly SiteController $siteController
+    ) {
+        parent::__construct();
+    }
+
     /**
      * -- This method is expected by Typo3, do not rename ou remove --
      *
@@ -58,8 +64,7 @@ class AddRedirectionCommand extends Command
 
         $io = new SymfonyStyle($input, $output);
 
-        $siteController = GeneralUtility::makeInstance(ObjectManager::class)->get(SiteController::class);
-        $status = $siteController->addRedirection($fromDomain, $toDomain);
+        $status = $this->siteController->addRedirection($fromDomain, $toDomain);
 
         if ($status == SiteController::REDIRECTION_UPDATED) {
             $io->success(sprintf("A existing redirection has been restored and updated"));

+ 10 - 6
ot_admin/Classes/Command/ClearObsoleteWebsitesSiteCommand.php

@@ -22,6 +22,13 @@ use TYPO3\CMS\Extbase\Object\ObjectManager;
  */
 class ClearObsoleteWebsitesSiteCommand extends Command
 {
+    public function __construct(
+        private readonly SiteController $siteController,
+        private readonly ConnectionPool $connectionPool
+    ) {
+        parent::__construct();
+    }
+
     /**
      * -- This method is expected by Typo3, do not rename ou remove --
      *
@@ -65,10 +72,7 @@ class ClearObsoleteWebsitesSiteCommand extends Command
 
         $io = new SymfonyStyle($input, $output);
 
-        $siteController = GeneralUtility::makeInstance(ObjectManager::class)->get(SiteController::class);
-
-        $connectionPool = GeneralUtility::makeInstance(ConnectionPool::class);
-        $queryBuilder = $connectionPool->getQueryBuilderForTable('ot_websites');
+        $queryBuilder = $this->connectionPool->getQueryBuilderForTable('ot_websites');
         $sites = $queryBuilder
             ->select('organization_id')
             ->from('ot_websites')
@@ -81,14 +85,14 @@ class ClearObsoleteWebsitesSiteCommand extends Command
         $n = 0;
         foreach ($sites as $site) {
             try {
-                $siteController->fetchOrganization($site['organization_id']);
+                $this->siteController->fetchOrganization($site['organization_id']);
             } catch (NoSuchOrganizationException $e) {
                 $n++;
                 if ($preview) {
                     $io->info('Site ' . $site['uid'] . ' to delete : ' . $site['organization_id'] . ' [' . $site['organization_name'] . ']');
                     continue;
                 }
-                $siteController->deleteSiteAction($site['organization_id']);
+                $this->siteController->deleteSiteAction($site['organization_id']);
                 $io->info('Website ' . $site['uid'] . ' deleted : ' . $site['organization_id'] . ' [' . $site['organization_name'] . ']');
             }
             /** @noinspection DisconnectedForeachInstructionInspection */

+ 6 - 3
ot_admin/Classes/Command/ClearSiteCacheCommand.php

@@ -17,12 +17,16 @@ use TYPO3\CMS\Extbase\Object\ObjectManager;
  * This CLI command clears the cache of an existing organization's website
  *
  * By default, this command will only clear the frontend cache.
- * Pass the '-a / --all' option to clear all of the typo3 caches.
+ * Pass the '-a / --all' option to clear all the typo3 caches.
  *
  * @package Opentalent\OtAdmin\Command
  */
 class ClearSiteCacheCommand extends Command
 {
+    public function __construct(
+        private readonly SiteController $siteController
+    ) {}
+
     /**
      * -- This method is expected by Typo3, do not rename ou remove --
      *
@@ -62,8 +66,7 @@ class ClearSiteCacheCommand extends Command
 
         $io = new SymfonyStyle($input, $output);
 
-        $siteController = GeneralUtility::makeInstance(ObjectManager::class)->get(SiteController::class);
-        $rootUid = $siteController->clearSiteCacheAction($org_id, $clearAll);
+        $rootUid = $this->siteController->clearSiteCacheAction($org_id, $clearAll);
 
         $io->success(sprintf("The cache has been cleared for the website with root uid " . $rootUid . ""));
         return 0;

+ 7 - 2
ot_admin/Classes/Command/CreateSiteCommand.php

@@ -21,6 +21,12 @@ use TYPO3\CMS\Extbase\Object\ObjectManager;
  */
 class CreateSiteCommand extends Command
 {
+    public function __construct(
+        private readonly SiteController $siteController
+    ) {
+        parent::__construct();
+    }
+
     /**
      * -- This method is expected by Typo3, do not rename ou remove --
      *
@@ -63,8 +69,7 @@ class CreateSiteCommand extends Command
 
         $io = new SymfonyStyle($input, $output);
 
-        $siteController = GeneralUtility::makeInstance(ObjectManager::class)->get(SiteController::class);
-        $rootUid = $siteController->createSiteAction($org_id);
+        $rootUid = $this->siteController->createSiteAction($org_id);
 
         $io->success(sprintf("A new website has been created with root page uid=" . $rootUid));
         return 0;

+ 6 - 3
ot_admin/Classes/Command/DeleteSiteCommand.php

@@ -20,7 +20,11 @@ use TYPO3\CMS\Extbase\Object\ObjectManager;
  */
 class DeleteSiteCommand extends Command
 {
-
+    public function __construct(
+        private readonly SiteController $siteController
+    ) {
+        parent::__construct();
+    }
 
     /**
      * -- This method is expected by Typo3, do not rename ou remove --
@@ -82,8 +86,7 @@ class DeleteSiteCommand extends Command
 
         $io = new SymfonyStyle($input, $output);
 
-        $siteController = GeneralUtility::makeInstance(ObjectManager::class)->get(SiteController::class);
-        $rootUid = $siteController->deleteSiteAction($org_id, $hard, !$noRedirect, $force);
+        $rootUid = $this->siteController->deleteSiteAction($org_id, $hard, !$noRedirect, $force);
 
         if ($hard) {
             $io->success(sprintf("The website with root uid " . $rootUid . " has been permanently deleted"));

+ 7 - 2
ot_admin/Classes/Command/GetSiteStatusCommand.php

@@ -21,6 +21,12 @@ use TYPO3\CMS\Extbase\Object\ObjectManager;
  */
 class GetSiteStatusCommand extends Command
 {
+    public function __construct(
+        private readonly SiteController $siteController
+    ) {
+        parent::__construct();
+    }
+
     /**
      * -- This method is expected by Typo3, do not rename ou remove --
      *
@@ -63,8 +69,7 @@ class GetSiteStatusCommand extends Command
 
         $io = new SymfonyStyle($input, $output);
 
-        $siteController = GeneralUtility::makeInstance(ObjectManager::class)->get(SiteController::class);
-        $status = $siteController->getSiteStatusAction($org_id, $full);
+        $status = $this->siteController->getSiteStatusAction($org_id, $full);
 
         $headers = [];
         $values = [];

+ 7 - 2
ot_admin/Classes/Command/RegenConfigFilesCommand.php

@@ -24,6 +24,12 @@ use TYPO3\CMS\Extbase\Object\ObjectManager;
  */
 class RegenConfigFilesCommand extends Command
 {
+    public function __construct(
+        private readonly SiteController $siteController
+    ) {
+        parent::__construct();
+    }
+
     /**
      * -- This method is expected by Typo3, do not rename ou remove --
      *
@@ -49,8 +55,7 @@ class RegenConfigFilesCommand extends Command
     protected function execute(InputInterface $input, OutputInterface $output)
     {
         $io = new SymfonyStyle($input, $output);
-        $siteController = GeneralUtility::makeInstance(ObjectManager::class)->get(SiteController::class);
-        $siteController->regenConfigFilesAction();
+        $this->siteController->regenConfigFilesAction();
         $io->success(sprintf("The config files were recreated"));
         return 0;
     }

+ 7 - 2
ot_admin/Classes/Command/RemoveRedirectionCommand.php

@@ -20,6 +20,12 @@ use TYPO3\CMS\Extbase\Object\ObjectManager;
  */
 class RemoveRedirectionCommand extends Command
 {
+    public function __construct(
+        private readonly SiteController $siteController
+    ) {
+        parent::__construct();
+    }
+
     /**
      * -- This method is expected by Typo3, do not rename ou remove --
      *
@@ -60,8 +66,7 @@ class RemoveRedirectionCommand extends Command
 
         $io = new SymfonyStyle($input, $output);
 
-        $siteController = GeneralUtility::makeInstance(ObjectManager::class)->get(SiteController::class);
-        $count = $siteController->removeRedirectionsFrom($fromDomain, $hard);
+        $count = $this->siteController->removeRedirectionsFrom($fromDomain, $hard);
 
         $actionName = $hard ? 'hardly-deleted' : 'deleted';
         $io->success(sprintf("$count existing redirections from $fromDomain have been $actionName"));

+ 10 - 6
ot_admin/Classes/Command/ResetBeUserPermsCommand.php

@@ -22,6 +22,13 @@ use TYPO3\CMS\Extbase\Object\ObjectManager;
  */
 class ResetBeUserPermsCommand extends Command
 {
+    public function __construct(
+        private readonly SiteController $siteController,
+        private readonly ConnectionPool $connectionPool
+    ) {
+        parent::__construct();
+    }
+
     /**
      * -- This method is expected by Typo3, do not rename ou remove --
      *
@@ -78,11 +85,8 @@ class ResetBeUserPermsCommand extends Command
 
         $io = new SymfonyStyle($input, $output);
 
-        $siteController = GeneralUtility::makeInstance(ObjectManager::class)->get(SiteController::class);
-
         if ($all) {
-            $connectionPool = GeneralUtility::makeInstance(ConnectionPool::class);
-            $queryBuilder = $connectionPool->getQueryBuilderForTable('ot_websites');
+            $queryBuilder = $this->connectionPool->getQueryBuilderForTable('ot_websites');
             $sites = $queryBuilder
                 ->select('organization_id')
                 ->from('ot_websites')
@@ -96,7 +100,7 @@ class ResetBeUserPermsCommand extends Command
             foreach ($sites as $site) {
                 $org_id = $site['organization_id'];
                 try {
-                    $siteController->resetBeUserPermsAction($org_id, $create);
+                    $this->siteController->resetBeUserPermsAction($org_id, $create);
                 } catch (\Throwable $e) {
                     $io->error('Organization Id: ' . $org_id . ' - ' . $e->getMessage());
                 }
@@ -106,7 +110,7 @@ class ResetBeUserPermsCommand extends Command
 
             $io->success(sprintf("Be users permissions were reset for every website"));
         } else {
-            $rootUid = $siteController->resetBeUserPermsAction($org_id, $create);
+            $rootUid = $this->siteController->resetBeUserPermsAction($org_id, $create);
             $io->success(sprintf("The website with root uid " . $rootUid . " had its be users permissions reset"));
         }
         return 0;

+ 8 - 3
ot_admin/Classes/Command/ScanCommand.php

@@ -3,6 +3,7 @@
 namespace Opentalent\OtAdmin\Command;
 
 use Opentalent\OtAdmin\Controller\ScanController;
+use Opentalent\OtAdmin\Controller\SiteController;
 use Symfony\Component\Console\Command\Command;
 use Symfony\Component\Console\Input\InputInterface;
 use Symfony\Component\Console\Input\InputOption;
@@ -20,6 +21,12 @@ use TYPO3\CMS\Extbase\Object\ObjectManager;
  */
 class ScanCommand extends Command
 {
+    public function __construct(
+        private readonly ScanController $scanController
+    ) {
+        parent::__construct();
+    }
+
     /**
      * -- This method is expected by Typo3, do not rename ou remove --
      *
@@ -76,12 +83,10 @@ class ScanCommand extends Command
         }
 
         // perform the scan
-        $scanController = GeneralUtility::makeInstance(ObjectManager::class)->get(ScanController::class);
-
         $progressBar = $io->createProgressBar();
         $progressBar->display();
 
-        $scan = $scanController->scanAllAction(
+        $scan = $this->scanController->scanAllAction(
             $deep,
             function ($i, $total) use ($progressBar) {
                 $progressBar->setProgress($i);

+ 7 - 2
ot_admin/Classes/Command/SetSiteDomainCommand.php

@@ -20,6 +20,12 @@ use TYPO3\CMS\Extbase\Object\ObjectManager;
  */
 class SetSiteDomainCommand extends Command
 {
+    public function __construct(
+        private readonly SiteController $siteController
+    ) {
+        parent::__construct();
+    }
+
     /**
      * -- This method is expected by Typo3, do not rename ou remove --
      *
@@ -71,8 +77,7 @@ class SetSiteDomainCommand extends Command
 
         $io = new SymfonyStyle($input, $output);
 
-        $siteController = GeneralUtility::makeInstance(ObjectManager::class)->get(SiteController::class);
-        $rootUid = $siteController->setSiteCustomDomainAction($org_id, $domain, $redirect);
+        $rootUid = $this->siteController->setSiteCustomDomainAction($org_id, $domain, $redirect);
 
         $io->success(sprintf("The website with root uid " . $rootUid . " domain has been set to " . $domain));
         return 0;

+ 8 - 5
ot_admin/Classes/Command/UndeleteSiteCommand.php

@@ -20,6 +20,12 @@ use TYPO3\CMS\Extbase\Object\ObjectManager;
  */
 class UndeleteSiteCommand extends Command
 {
+    public function __construct(
+        private readonly SiteController $siteController
+    ) {
+        parent::__construct();
+    }
+
     /**
      * -- This method is expected by Typo3, do not rename ou remove --
      *
@@ -57,13 +63,10 @@ class UndeleteSiteCommand extends Command
 
         $io = new SymfonyStyle($input, $output);
 
-        $siteController = GeneralUtility::makeInstance(ObjectManager::class)->get(SiteController::class);
-        $rootUid = $siteController->undeleteSiteAction($org_id);
-        $siteController->updateSiteAction($org_id);
+        $rootUid = $this->siteController->undeleteSiteAction($org_id);
+        $this->siteController->updateSiteAction($org_id);
 
         $io->success(sprintf("The website with root uid " . $rootUid . " has been restored"));
         return 0;
-
     }
-
 }

+ 10 - 6
ot_admin/Classes/Command/UpdateSiteCommand.php

@@ -23,6 +23,13 @@ use TYPO3\CMS\Extbase\Object\ObjectManager;
  */
 class UpdateSiteCommand extends Command
 {
+    public function __construct(
+        private readonly SiteController $siteController,
+        private readonly ConnectionPool $connectionPool
+    ) {
+        parent::__construct();
+    }
+
     /**
      * -- This method is expected by Typo3, do not rename ou remove --
      *
@@ -90,11 +97,8 @@ class UpdateSiteCommand extends Command
 
         $io = new SymfonyStyle($input, $output);
 
-        $siteController = GeneralUtility::makeInstance(ObjectManager::class)->get(SiteController::class);
-
         if ($all) {
-            $connectionPool = GeneralUtility::makeInstance(ConnectionPool::class);
-            $queryBuilder = $connectionPool->getQueryBuilderForTable('ot_websites');
+            $queryBuilder = $this->connectionPool->getQueryBuilderForTable('ot_websites');
             $sites = $queryBuilder
                 ->select('organization_id')
                 ->from('ot_websites')
@@ -108,7 +112,7 @@ class UpdateSiteCommand extends Command
             foreach ($sites as $site) {
                 $org_id = $site['organization_id'];
                 try {
-                    $siteController->updateSiteAction($org_id);
+                    $this->siteController->updateSiteAction($org_id);
                 } catch (NoSuchOrganizationException $e) {
                     if ($delete) {
                         $siteController->deleteSiteAction($org_id);
@@ -124,7 +128,7 @@ class UpdateSiteCommand extends Command
 
             $io->success(sprintf("The websites have all been updated"));
         } else {
-            $rootUid = $siteController->updateSiteAction($org_id);
+            $rootUid = $this->siteController->updateSiteAction($org_id);
             $io->success(sprintf("The website with root uid " . $rootUid . " has been updated"));
         }
         return 0;

+ 10 - 5
ot_admin/Classes/Controller/ScanController.php

@@ -5,6 +5,7 @@ namespace Opentalent\OtAdmin\Controller;
 use Opentalent\OtAdmin\Domain\Entity\ScanReport;
 use Opentalent\OtCore\Controller\ActionController;
 use Opentalent\OtCore\Domain\Repository\OrganizationRepository;
+use TYPO3\CMS\Core\Database\ConnectionPool;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 use TYPO3\CMS\Extbase\Object\ObjectManager;
 
@@ -13,6 +14,13 @@ use TYPO3\CMS\Extbase\Object\ObjectManager;
  */
 class ScanController extends ActionController
 {
+    public function __construct(
+        private readonly SiteController $siteController,
+        private readonly OrganizationRepository $organizationRepository
+    ) {
+        parent::__construct();
+    }
+
     /**
      * Perform a full scan of the Typo3 DB, and confront it to the
      * Opentalent organizations list.
@@ -24,19 +32,16 @@ class ScanController extends ActionController
      */
     public function scanAllAction(bool $fullScan = false, ?callable $progressCallback = null): ScanReport
     {
-        $organizationRepository = GeneralUtility::makeInstance(ObjectManager::class)->get(OrganizationRepository::class);
-        $siteController = GeneralUtility::makeInstance(ObjectManager::class)->get(SiteController::class);
-
         $report = new ScanReport();
 
-        $organizationsCollection = $organizationRepository->getAll();
+        $organizationsCollection = $this->organizationRepository->getAll();
         $i = 0;
         $total = count($organizationsCollection->getMembers());
 
         foreach ($organizationsCollection->getMembers() as $organization) {
             $i++;
 
-            $status = $siteController->getSiteStatusAction($organization->getId(), $fullScan);
+            $status = $this->siteController->getSiteStatusAction($organization->getId(), $fullScan);
 
             $report->setResultFor($organization->getId(), $status);
 

+ 13 - 4
ot_admin/Classes/Controller/SiteController.php

@@ -124,6 +124,16 @@ class SiteController extends ActionController
         $this->cacheManager = $cacheManager;
     }
 
+    /**
+     * @var OtCacheManager
+     */
+    private OtCacheManager $otCacheManager;
+
+    public function injectOtCacheManager(OtCacheManager $otCacheManager): void
+    {
+        $this->otCacheManager = $otCacheManager;
+    }
+
     /**
      * @var OrganizationRepository
      */
@@ -733,7 +743,7 @@ class SiteController extends ActionController
             }
 
             // ## Clear the Typo3 cache for the website
-            OtCacheManager::clearSiteCache($rootUid, true);
+            $this->otCacheManager->clearSiteCache($rootUid, true);
 
         } catch(\Throwable $e) {
             // rollback
@@ -1213,7 +1223,7 @@ class SiteController extends ActionController
     {
         $rootUid = $this->otWebsiteRepository->findRootUidForOrganization($organizationId);
 
-        OtCacheManager::clearSiteCache($rootUid, $clearAll);
+        $this->otCacheManager->clearSiteCache($rootUid, $clearAll);
 
         return $rootUid;
     }
@@ -1226,7 +1236,6 @@ class SiteController extends ActionController
      * @throws NoSuchOrganizationException
      * @throws NoSuchRecordException
      * @throws NoSuchWebsiteException
-     * @throws Exception
      */
     private function scanSite(int $organizationId): array
     {
@@ -1442,7 +1451,7 @@ class SiteController extends ActionController
             } catch (\RuntimeException $e) {} // silent the error until this https://assistance.opentalent.fr/browse/V8-3344
         }
 
-        OtCacheManager::clearSiteCache($rootUid, true);
+        $this->otCacheManager->clearSiteCache($rootUid, true);
         return $rootUid;
     }
 

+ 17 - 26
ot_admin/Classes/Http/ApiController.php

@@ -7,10 +7,10 @@ use Opentalent\OtAdmin\Controller\ScanController;
 use Opentalent\OtAdmin\Controller\SiteController;
 use Psr\Log\LoggerAwareInterface;
 use Psr\Log\LoggerAwareTrait;
+use TYPO3\CMS\Core\Database\ConnectionPool;
 use TYPO3\CMS\Core\Http\JsonResponse;
 use TYPO3\CMS\Core\Http\ServerRequest;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
-use TYPO3\CMS\Extbase\Object\ObjectManager;
 
 /**
  * Actions for Http API calls
@@ -21,7 +21,7 @@ class ApiController implements LoggerAwareInterface
 {
     use LoggerAwareTrait;
 
-    const ALLOWED_IPS = [
+    const array ALLOWED_IPS = [
         '/^127\.0\.0\.[0-1]$/', // Localhost
         '/^localhost$/',  // Localhost
         '/^10\.8\.0\.\d{1,3}$/', // 10.8.0.[0-255] - VPN
@@ -30,6 +30,10 @@ class ApiController implements LoggerAwareInterface
         '/^172\.20\.\d{1,3}\.\d{1,3}$/',  // 172.20.[0-255].[0-255] - Docker
     ];
 
+    public function __construct(
+        private readonly SiteController $siteController
+    ) {}
+
     /**
      * Returns true if the client Ip is allowed
      *
@@ -95,9 +99,8 @@ class ApiController implements LoggerAwareInterface
 
         $organizationId = $this->getOrganizationId($request);
 
-        $controller = GeneralUtility::makeInstance(ObjectManager::class)->get(SiteController::class);
 
-        $infos = $controller->getSiteInfosAction($organizationId);
+        $infos = $this->siteController->getSiteInfosAction($organizationId);
 
         return new JsonResponse($infos);
     }
@@ -118,8 +121,7 @@ class ApiController implements LoggerAwareInterface
 
         $organizationId = $this->getOrganizationId($request);
 
-        $controller = GeneralUtility::makeInstance(ObjectManager::class)->get(SiteController::class);
-        $rootUid = $controller->createSiteAction($organizationId);
+        $rootUid = $this->siteController->createSiteAction($organizationId);
 
         $this->logger->info(sprintf(
             "OtAdmin API: A new website has been created with root page uid=" . $rootUid .
@@ -151,8 +153,7 @@ class ApiController implements LoggerAwareInterface
         $organizationId = $this->getOrganizationId($request);
         $deep = (isset($queryParams['deep']) && $queryParams['deep']);
 
-        $controller = GeneralUtility::makeInstance(ObjectManager::class)->get(SiteController::class);
-        $rootUid = $controller->updateSiteAction($organizationId, $deep);
+        $rootUid = $this->siteController->updateSiteAction($organizationId, $deep);
 
         $this->logger->info(sprintf(
             "OtAdmin API: The website with root uid " . $rootUid . " has been updated " .
@@ -184,8 +185,7 @@ class ApiController implements LoggerAwareInterface
         $fromDomain = (isset($queryParams['from-domain']) && $queryParams['from-domain']);
         $toDomain = (isset($queryParams['to-domain']) && $queryParams['to-domain']);
 
-        $controller = GeneralUtility::makeInstance(ObjectManager::class)->get(SiteController::class);
-        $res = $controller->addRedirection($fromDomain, $toDomain);
+        $res = $this->siteController->addRedirection($fromDomain, $toDomain);
 
         if ($res === SiteController::REDIRECTION_UPDATED) {
             $msg = "An existing redirection has been updated ";
@@ -221,8 +221,7 @@ class ApiController implements LoggerAwareInterface
 
         $params = $request->getQueryParams();
 
-        $controller = GeneralUtility::makeInstance(ObjectManager::class)->get(SiteController::class);
-        $rootUid = $controller->deleteSiteAction($organizationId);
+        $rootUid = $this->siteController->deleteSiteAction($organizationId);
 
         $this->logger->info(sprintf(
             "OtAdmin API: The website with root uid " . $rootUid . " has been soft-deleted " .
@@ -253,8 +252,7 @@ class ApiController implements LoggerAwareInterface
 
         $organizationId = $this->getOrganizationId($request);
 
-        $controller = GeneralUtility::makeInstance(ObjectManager::class)->get(SiteController::class);
-        $rootUid = $controller->undeleteSiteAction($organizationId);
+        $rootUid = $this->siteController->undeleteSiteAction($organizationId);
 
         $this->logger->info(sprintf(
             "OtAdmin API: The website with root uid " . $rootUid . " has been restored " .
@@ -288,8 +286,7 @@ class ApiController implements LoggerAwareInterface
         $queryParams = $request->getQueryParams();
         $clearAll = (isset($queryParams['all']) && $queryParams['all']);;
 
-        $controller = GeneralUtility::makeInstance(ObjectManager::class)->get(SiteController::class);
-        $rootUid = $controller->clearSiteCacheAction($organizationId, $clearAll);
+        $rootUid = $this->siteController->clearSiteCacheAction($organizationId, $clearAll);
 
         return new JsonResponse(
             [
@@ -324,8 +321,7 @@ class ApiController implements LoggerAwareInterface
         }
         $redirect = (isset($queryParams['redirect']) && $queryParams['redirect']);
 
-        $controller = GeneralUtility::makeInstance(ObjectManager::class)->get(SiteController::class);
-        $rootUid = $controller->setSiteCustomDomainAction($organizationId, $domain, $redirect);
+        $rootUid = $this->siteController->setSiteCustomDomainAction($organizationId, $domain, $redirect);
 
         return new JsonResponse(
             [
@@ -352,8 +348,7 @@ class ApiController implements LoggerAwareInterface
 
         $organizationId = $this->getOrganizationId($request);
 
-        $controller = GeneralUtility::makeInstance(ObjectManager::class)->get(SiteController::class);
-        $rootUid = $controller->resetBeUserPermsAction($organizationId);
+        $rootUid = $this->siteController->resetBeUserPermsAction($organizationId);
 
         return new JsonResponse(
             [
@@ -380,11 +375,9 @@ class ApiController implements LoggerAwareInterface
 
         $organizationId = $this->getOrganizationId($request);
 
-        $controller = GeneralUtility::makeInstance(ObjectManager::class)->get(SiteController::class);
-
         $queryParams = $request->getQueryParams();
         $full = (isset($queryParams['full']) && $queryParams['full']);
-        $status = $controller->getSiteStatusAction($organizationId, $full);
+        $status = $this->siteController->getSiteStatusAction($organizationId, $full);
 
         return new JsonResponse($status->toArray());
     }
@@ -402,11 +395,9 @@ class ApiController implements LoggerAwareInterface
     {
         $this->assertIpAllowed();
 
-        $controller = GeneralUtility::makeInstance(ObjectManager::class)->get(ScanController::class);
-
         $queryParams = $request->getQueryParams();
         $full = (isset($queryParams['full']) && $queryParams['full']);
-        $results = $controller->scanAllAction($full);
+        $results = $this->siteController->scanAllAction($full);
 
         return new JsonResponse($results);
     }

+ 12 - 11
ot_core/Classes/Cache/OtCacheManager.php

@@ -5,11 +5,16 @@ namespace Opentalent\OtCore\Cache;
 use Opentalent\OtCore\Website\OtPageRepository;
 use TYPO3\CMS\Core\Database\ConnectionPool;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
-use TYPO3\CMS\Extbase\Object\ObjectManager;
 use TYPO3\CMS\Core\Cache\CacheManager;
 
 class OtCacheManager
 {
+    public function __construct(
+        private readonly OtPageRepository $otPageRepository,
+        private readonly ConnectionPool $connectionPool,
+        private readonly CacheManager $cacheManager
+    ) {}
+
     /**
      * Clears the page cache
      *
@@ -29,28 +34,24 @@ class OtCacheManager
      * @param int $pageUid
      * @param bool $clearAll if true, all caches will be cleared, and not only the frontend one
      */
-    public static function clearSiteCache(int $pageUid, bool $clearAll = false) {
+    public function clearSiteCache(int $pageUid, bool $clearAll = false) {
 
-        $pageRepository = GeneralUtility::makeInstance(ObjectManager::class)->get(OtPageRepository::class);
-        $rootPage = $pageRepository->getRootPageFor($pageUid);
-        $pages = $pageRepository->getAllSubpagesForPage($rootPage['uid']);
+        $rootPage = $this->otPageRepository->getRootPageFor($pageUid);
+        $pages = $this->otPageRepository->getAllSubpagesForPage($rootPage['uid']);
         $pages[] = $rootPage;
 
-        $cacheManager = GeneralUtility::makeInstance(CacheManager::class);
-
         $tags = array_map(function ($page) {
             return 'pageId_' . $page['uid'];
         }, $pages);
 
         if ($clearAll) {
-            $cacheManager->flushCachesByTags($tags);
+            $this->cacheManager->flushCachesByTags($tags);
         } else {
-            $cacheManager->flushCachesInGroupByTags('pages', $tags);
+            $this->cacheManager->flushCachesInGroupByTags('pages', $tags);
         }
 
         // << BUGFIX: without this, the fluid templates caches are not cleared
-        $connectionPool = GeneralUtility::makeInstance(ConnectionPool::class);
-        $cnn = $connectionPool->getConnectionByName('Default');
+        $cnn = $this->connectionPool->getConnectionByName('Default');
         $cnn->beginTransaction();
         $sql = "update typo3.cache_hash h inner join typo3.cache_hash_tags t on h.id = t.id
                 set h.expires = 0

+ 2 - 4
ot_core/Classes/Controller/SelectedSiteController.php

@@ -2,10 +2,12 @@
 
 namespace Opentalent\OtCore\Controller;
 
+use Opentalent\OtAdmin\Controller\SiteController;
 use Opentalent\OtCore\Exception\NoSiteSelected;
 use Opentalent\OtCore\Exception\NoSuchWebsiteException;
 use Opentalent\OtCore\Website\OtPageRepository;
 use Psr\Http\Message\ResponseInterface;
+use TYPO3\CMS\Core\Database\ConnectionPool;
 use TYPO3\CMS\Extbase\Mvc\Exception\StopActionException;
 use TYPO3\CMS\Extbase\Mvc\RequestInterface;
 use TYPO3\CMS\Extbase\Object\ObjectManager;
@@ -58,10 +60,6 @@ class SelectedSiteController extends ActionController
             // No db mountpoint has been set up, or more than one.
             // Now we check if a site's page is selected
             try {
-                if ($this->otPageRepository == null) {
-                    $objectManager = new ObjectManager();
-                    $this->otPageRepository = $objectManager->get(OtPageRepository::class);
-                }
                 $this->currentRootUid = $this->otPageRepository->getCurrentBeRootUid();
             } catch (NoSiteSelected $e) {
                 $this->currentRootUid = null;

+ 12 - 3
ot_optimizer/Classes/Middleware/Frontend/OtPageResolver.php

@@ -9,12 +9,22 @@ use Psr\Http\Message\ResponseInterface;
 use Psr\Http\Message\ServerRequestInterface;
 use Psr\Http\Server\RequestHandlerInterface;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
-use TYPO3\CMS\Extbase\Object\ObjectManager;
 use TYPO3\CMS\Frontend\Controller\ErrorController;
 use TYPO3\CMS\Frontend\Page\PageAccessFailureReasons;
 
 class OtPageResolver extends \TYPO3\CMS\Frontend\Middleware\PageResolver
 {
+    private OtWebsiteRepository $otWebsiteRepository;
+
+    /**
+     * @param OtWebsiteRepository $otWebsiteRepository
+     * @return void
+     */
+    public function injectOtWebsiteRepository(OtWebsiteRepository $otWebsiteRepository)
+    {
+        $this->otWebsiteRepository = $otWebsiteRepository;
+    }
+
     /**
      * Resolve the page ID
      *
@@ -34,7 +44,6 @@ class OtPageResolver extends \TYPO3\CMS\Frontend\Middleware\PageResolver
             return parent::process($request, $handler);
         }
 
-        $otWebsiteRepository = GeneralUtility::makeInstance(ObjectManager::class)->get(OtWebsiteRepository::class);
         $devMode = $_SERVER['TYPO3_CONTEXT'] == "Development";
 
         if (!$GLOBALS['TYPO3_REQUEST']) {
@@ -64,7 +73,7 @@ class OtPageResolver extends \TYPO3\CMS\Frontend\Middleware\PageResolver
             )
             && $GLOBALS['BE_USER'];
 
-        $pageUid = $otWebsiteRepository->matchUriToPage($website, $request->getUri(), $devMode, !$requestedFromBE);
+        $pageUid = $this->otWebsiteRepository->matchUriToPage($website, $request->getUri(), $devMode, !$requestedFromBE);
 
         if (!$pageUid > 0) {
             return GeneralUtility::makeInstance(ErrorController::class)->pageNotFoundAction(

+ 6 - 6
ot_stats/Classes/Controller/OtStatsController.php

@@ -4,6 +4,7 @@ namespace Opentalent\OtStats\Controller;
 
 use Opentalent\OtCore\Controller\SelectedSiteController;
 use Opentalent\OtCore\Logging\OtLogger;
+use Opentalent\OtCore\Website\OtWebsiteRepository;
 use Opentalent\OtStats\Domain\Repository\MatomoWebsiteRepository;
 use Psr\Http\Message\ResponseInterface;
 use TYPO3\CMS\Core\Messaging\AbstractMessage;
@@ -18,6 +19,9 @@ use TYPO3\CMS\Extbase\Object\ObjectManager;
  * @author olivier.massot
  */
 class OtStatsController extends SelectedSiteController {
+    public function __construct(
+        private readonly MatomoWebsiteRepository $matomoWebsiteRepository,
+    ) {}
 
     /**
      * Access token of the 'typo3' user in matomo
@@ -63,10 +67,8 @@ class OtStatsController extends SelectedSiteController {
      * save its id
      */
     public function enableStatsAction(): ResponseInterface {
-        $matomoRepository = GeneralUtility::makeInstance(ObjectManager::class)->get(MatomoWebsiteRepository::class);
-
         try {
-            $matomoRepository->createFor($this->currentRootUid);
+            $this->matomoWebsiteRepository->createFor($this->currentRootUid);
         } catch (\RuntimeException $e) {
             OtLogger::error("OtStats - " . $e);
 
@@ -92,10 +94,8 @@ class OtStatsController extends SelectedSiteController {
      */
     public function disableStatsAction(int $rootUid): ResponseInterface {
 
-        $matomoRepository = GeneralUtility::makeInstance(ObjectManager::class)->get(MatomoWebsiteRepository::class);
-
         try {
-            $matomoRepository->disableFor($rootUid);
+            $this->matomoWebsiteRepository->disableFor($rootUid);
         } catch (\RuntimeException $e) {
             OtLogger::error("OtStats - " . $e);
             $this->addFlashMessage(

+ 7 - 7
ot_stats/Classes/Domain/Repository/MatomoWebsiteRepository.php

@@ -43,7 +43,10 @@ class MatomoWebsiteRepository
         $this->connectionPool = $connectionPool;
     }
 
-    public function __construct()
+    public function __construct(
+        private readonly OtPageRepository $otPageRepository,
+        private readonly OtWebsiteRepository $otWebsiteRepository
+    )
     {
         // Connection to the Matomo DB
         $this->matomoCnn = new PDO(
@@ -162,14 +165,11 @@ class MatomoWebsiteRepository
      * @throws \Exception
      */
     public function createFor(int $rootUid) {
-        $otPageRepository = GeneralUtility::makeInstance(ObjectManager::class)->get(OtPageRepository::class);
-
         // Just to make sure this page is actually the root page
-        $rootPage = $otPageRepository->getRootPageFor($rootUid);
+        $rootPage = $this->otPageRepository->getRootPageFor($rootUid);
         $rootUid = $rootPage['uid'];
 
-        $otWebsiteRepository = GeneralUtility::makeInstance(ObjectManager::class)->get(OtWebsiteRepository::class);
-        $website = $otWebsiteRepository->getWebsiteByUid($rootPage['ot_website_uid']);
+        $website = $this->otWebsiteRepository->getWebsiteByUid($rootPage['ot_website_uid']);
 
         // Retrieve current site informations
         $isDev = ($_SERVER['TYPO3_CONTEXT'] == 'Development');
@@ -182,7 +182,7 @@ class MatomoWebsiteRepository
         if ($isDev) {
             $uri = rtrim($_SERVER['HTTP_HOST'], '/') . '/' . $website['subdomain'];
         } else {
-            $uri = $otWebsiteRepository->resolveWebsiteDomain($website);
+            $uri = $this->otWebsiteRepository->resolveWebsiteDomain($website);
         }
 
         if (!preg_match(self::DOMAIN_VALIDATION, $uri)) {

+ 4 - 3
ot_stats/Classes/Middleware/RequestHandler.php

@@ -24,7 +24,9 @@ class RequestHandler implements MiddlewareInterface
     const LAYOUTS_ROOT_PATHS = 'EXT:ot_stats/Resources/Private/Layouts';
     const TEMPLATE_FILE = self::TEMPLATES_ROOT_PATHS . '/Header/Include.html';
 
-    public function __construct() {}
+    public function __construct(
+        private readonly OtWebsiteRepository $otWebsiteRepository,
+    ) {}
 
     /**
      * Process the frontend request to insert the matomo script in the header
@@ -38,8 +40,7 @@ class RequestHandler implements MiddlewareInterface
     {
 
         // Retrieve the current matomo site's id if set
-        $otWebsiteRepository = GeneralUtility::makeInstance(ObjectManager::class)->get(OtWebsiteRepository::class);
-        $website = $otWebsiteRepository->getCurrentWebsiteFromFEGlobals();
+        $website = $this->otWebsiteRepository->getCurrentWebsiteFromFEGlobals();
         $matomoSiteId = $website['matomo_site_id'];
 
         if (!$matomoSiteId > 0) {

+ 8 - 10
ot_stats/Classes/ViewHelpers/MatomoSiteIdViewHelper.php

@@ -4,6 +4,7 @@ namespace Opentalent\OtStats\ViewHelpers;
 
 
 use Closure;
+use Opentalent\OtCore\Exception\NoSuchWebsiteException;
 use Opentalent\OtCore\Website\OtWebsiteRepository;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 use TYPO3\CMS\Extbase\Object\ObjectManager;
@@ -21,23 +22,20 @@ use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper;
  */
 class MatomoSiteIdViewHelper extends AbstractViewHelper
 {
+    public function __construct(
+        private readonly OtWebsiteRepository $otWebsiteRepository,
+    ) {}
 
     /**
      * -- This method is expected by Fluid --
      * Renders the content as html
      *
-     * @param array $arguments
-     * @param Closure $renderChildrenClosure
-     * @param RenderingContextInterface $renderingContext
      * @return int|null
+     * @throws NoSuchWebsiteException
      */
-    public static function renderStatic(
-        array $arguments,
-        Closure $renderChildrenClosure,
-        RenderingContextInterface $renderingContext
-    ) {
-        $otWebsiteRepository = GeneralUtility::makeInstance(ObjectManager::class)->get(OtWebsiteRepository::class);
-        $website = $otWebsiteRepository->getCurrentWebsiteFromFEGlobals();
+    public function render(): ?int
+    {
+        $website = $this->otWebsiteRepository->getCurrentWebsiteFromFEGlobals();
         return $website['matomo_site_id'];
     }
 }

+ 9 - 14
ot_templating/Classes/Controller/OtCustomizerController.php

@@ -20,15 +20,11 @@ use TYPO3\CMS\Extbase\Object\ObjectManager;
  */
 class OtCustomizerController extends SelectedSiteController {
 
-    /**
-     * @var ConnectionPool
-     */
-    private $connectionPool;
-
-    public function injectConnectionPool(ConnectionPool $connectionPool)
-    {
-        $this->connectionPool = $connectionPool;
-    }
+    public function __construct(
+        private readonly ConnectionPool $connectionPool,
+        private readonly TemplateRepository $templateRepository,
+        private readonly OtCacheManager $otCacheManager,
+    ) {}
 
     /**
      * Index action (default action)
@@ -39,9 +35,8 @@ class OtCustomizerController extends SelectedSiteController {
         $this->view->assign('website', $this->currentWebsite);
         $this->view->assign('templates', TemplateRepository::templates);
 
-        $templateRepository = GeneralUtility::makeInstance(ObjectManager::class)->get(TemplateRepository::class);
-        $this->view->assign('currentTemplate', $templateRepository->getTemplate($this->currentWebsite));
-        $this->view->assign('preferences', $templateRepository->getTemplatePreferences($this->currentWebsite));
+        $this->view->assign('currentTemplate', $this->templateRepository->getTemplate($this->currentWebsite));
+        $this->view->assign('preferences', $this->templateRepository->getTemplatePreferences($this->currentWebsite));
         return $this->htmlResponse();
     }
 
@@ -59,7 +54,7 @@ class OtCustomizerController extends SelectedSiteController {
             ->execute();
 
         // Clear the site's cache
-        OtCacheManager::clearSiteCache($this->currentRootUid);
+        $this->otCacheManager->clearSiteCache($this->currentRootUid);
 
         $this->addFlashMessage($this->getLanguageService()->sL(
             'LLL:EXT:ot_templating/Resources/Private/Language/locallang.xlf:theme_updated'
@@ -97,7 +92,7 @@ class OtCustomizerController extends SelectedSiteController {
             ->execute();
 
         // Clear the site's cache
-        OtCacheManager::clearSiteCache($this->currentRootUid);
+        $this->otCacheManager->clearSiteCache($this->currentRootUid);
 
         $this->addFlashMessage($this->getLanguageService()->sL(
             'LLL:EXT:ot_templating/Resources/Private/Language/locallang.xlf:settings_updated'

+ 6 - 2
ot_templating/Classes/News/NewsFilter.php

@@ -4,14 +4,18 @@ namespace Opentalent\OtTemplating\News;
 
 use GeorgRinger\News\Utility\Page;
 use Opentalent\OtCore\Website\OtPageRepository;
+use Opentalent\OtCore\Website\OtWebsiteRepository;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 use TYPO3\CMS\Extbase\Object\ObjectManager;
 
 class NewsFilter
 {
+    public function __construct(
+        private readonly OtPageRepository $otPageRepository,
+    ) {}
+
     public function createDemandObjectFromSettings($params) {
-        $pageRepo = GeneralUtility::makeInstance(ObjectManager::class)->get(OtPageRepository::class);
-        $rootUid = $pageRepo->getRootPageFor($GLOBALS['TSFE']->id);
+        $rootUid = $this->otPageRepository->getRootPageFor($GLOBALS['TSFE']->id);
         $params['demand']->setStoragePage(Page::extendPidListByChildren(
             '' . $rootUid['uid'],
             5

+ 65 - 26
ot_templating/Classes/Page/ErrorHandler.php

@@ -20,17 +20,17 @@ use TYPO3\CMS\Fluid\View\TemplateView;
 
 class ErrorHandler implements PageErrorHandlerInterface
 {
-    const TEMPLATES_ROOT_PATHS = 'EXT:ot_templating/Resources/Private/Templates';
-    const LAYOUTS_ROOT_PATHS = 'EXT:ot_templating/Resources/Private/Layouts';
-    const PARTIALS_ROOT_PATHS = 'EXT:ot_templating/Resources/Private/Partials';
+    const string TEMPLATES_ROOT_PATHS = 'EXT:ot_templating/Resources/Private/Templates';
+    const string LAYOUTS_ROOT_PATHS = 'EXT:ot_templating/Resources/Private/Layouts';
+    const string PARTIALS_ROOT_PATHS = 'EXT:ot_templating/Resources/Private/Partials';
 
-    const TEMPLATE_FILES = [
+    const array TEMPLATE_FILES = [
         403 => self::TEMPLATES_ROOT_PATHS . '/Page/Error/403.html',
         404 => self::TEMPLATES_ROOT_PATHS . '/Page/Error/404.html',
         500 => self::TEMPLATES_ROOT_PATHS . '/Page/Error/500.html'
     ];
 
-    const REDIRECT_FALLBACK = 'https://opentalent.fr';
+    const string REDIRECT_FALLBACK = 'https://opentalent.fr';
 
     /**
      * Status code of the response
@@ -44,6 +44,12 @@ class ErrorHandler implements PageErrorHandlerInterface
      */
     protected array $errorHandlerConfiguration;
 
+    private OtWebsiteRepository $otWebsiteRepository;
+    private OtPageRepository $otPageRepository;
+    private ControllerContext $controllerContext;
+    private RenderingContext $renderingContext;
+    private Request $request;
+
     /**
      * @var ViewInterface
      */
@@ -55,22 +61,46 @@ class ErrorHandler implements PageErrorHandlerInterface
         $this->errorHandlerConfiguration = $configuration;
 
         $this->view = GeneralUtility::makeInstance(TemplateView::class);
+    }
 
-        $objectManager = GeneralUtility::makeInstance(ObjectManager::class);
-        $controllerContext = $objectManager->get(ControllerContext::class);
-        $renderingContext = $objectManager->get(RenderingContext::class);
-        $webRequest = $objectManager->get(Request::class);
-        $webRequest->setControllerExtensionName('ot_templating');
-        $controllerContext->setRequest($webRequest);
-        $renderingContext->setControllerContext($controllerContext);
+    /**
+     * @param OtWebsiteRepository $otWebsiteRepository
+     * @return void
+     */
+    public function injectOtWebsiteRepository(OtWebsiteRepository $otWebsiteRepository) {
+        $this->otWebsiteRepository = $otWebsiteRepository;
+    }
 
-        $this->view->setRenderingContext($renderingContext);
-        $this->view->setTemplateRootPaths([self::TEMPLATES_ROOT_PATHS]);
-        $this->view->setLayoutRootPaths([self::LAYOUTS_ROOT_PATHS]);
-        $this->view->setPartialRootPaths([self::PARTIALS_ROOT_PATHS]);
-        $this->view->setTemplatePathAndFilename(
-            GeneralUtility::getFileAbsFileName(self::TEMPLATE_FILES[$statusCode])
-        );
+    /**
+     * @param OtPageRepository $otWebsiteRepository
+     * @return void
+     */
+    public function injectOtPageRepository(OtPageRepository $otPageRepository) {
+        $this->otPageRepository = $otPageRepository;
+    }
+
+    /**
+     * @param ControllerContext $controllerContext
+     * @return void
+     */
+    public function injectControllerContext(ControllerContext $controllerContext) {
+        $this->controllerContext = $controllerContext;
+    }
+
+    /**
+     * @param RenderingContext $renderingContext
+     * @return void
+     */
+    public function injectRenderingContext(RenderingContext $renderingContext) {
+        $this->renderingContext = $renderingContext;
+    }
+
+    /**
+     * @param Request $request
+     * @return void
+     */
+    public function injectRequest(Request $request) {
+        $this->request = $request;
     }
 
     /**
@@ -84,6 +114,17 @@ class ErrorHandler implements PageErrorHandlerInterface
         string $message,
         array $reasons = []
     ): ResponseInterface {
+        $this->request->setControllerExtensionName('ot_templating');
+        $this->controllerContext->setRequest($this->request);
+        $this->renderingContext->setControllerContext($this->controllerContext);
+
+        $this->view->setRenderingContext($this->renderingContext);
+        $this->view->setTemplateRootPaths([self::TEMPLATES_ROOT_PATHS]);
+        $this->view->setLayoutRootPaths([self::LAYOUTS_ROOT_PATHS]);
+        $this->view->setPartialRootPaths([self::PARTIALS_ROOT_PATHS]);
+        $this->view->setTemplatePathAndFilename(
+            GeneralUtility::getFileAbsFileName(self::TEMPLATE_FILES[$this->statusCode])
+        );
 
         $homeUri = "https://opentalent.fr";
         $title = 'Page Introuvable';
@@ -91,21 +132,19 @@ class ErrorHandler implements PageErrorHandlerInterface
         // This variable aims to prevent redirection loop
         $isCircular = preg_match('/.*\/page-introuvable/', $request->getUri()->getPath());
 
-        $otWebRepository = GeneralUtility::makeInstance(ObjectManager::class)->get(OtWebsiteRepository::class);
-        $website = $otWebRepository->getCurrentWebsiteFromFEGlobals();
+        $website = $this->otWebsiteRepository->getCurrentWebsiteFromFEGlobals();
 
         if ($website && !$isCircular){
 
-            $homeUri = $otWebRepository->resolveWebsiteBaseUri($website);
-            $rootUid = $otWebRepository->getWebsiteRootUid($website['uid']);
+            $homeUri = $this->otWebsiteRepository->resolveWebsiteBaseUri($website);
+            $rootUid = $this->otWebsiteRepository->getWebsiteRootUid($website['uid']);
 
-            $pageRepository = GeneralUtility::makeInstance(ObjectManager::class)->get(OtPageRepository::class);
-            $rootPage = $pageRepository->getPage($rootUid);
+            $rootPage = $this->otPageRepository->getPage($rootUid);
             if (!empty($rootPage)) {
 
                 $title = $rootPage['title'];
 
-                $subPages = $pageRepository->getAllSubpagesForPage($rootUid, true);
+                $subPages = $this->otPageRepository->getAllSubpagesForPage($rootUid, true);
                 foreach ($subPages as $page) {
                     if ($page['tx_fed_page_controller_action'] == 'OpenTalent.OtTemplating->error/404') {
 

+ 13 - 15
ot_templating/Classes/ViewHelpers/EventsPage/GetIdViewHelper.php

@@ -5,6 +5,7 @@ namespace Opentalent\OtTemplating\ViewHelpers\EventsPage;
 use Closure;
 use Opentalent\OtCore\Website\OtPageRepository;
 use Opentalent\OtCore\ViewHelpers\OtAbstractViewHelper;
+use Opentalent\OtCore\Website\OtWebsiteRepository;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 use TYPO3\CMS\Extbase\Object\ObjectManager;
 use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface;
@@ -24,11 +25,15 @@ use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface;
  */
 class GetIdViewHelper extends OtAbstractViewHelper
 {
+    public function __construct(
+        private readonly OtPageRepository $otPageRepository,
+    ) {}
+
     /**
      * -- This method is expected by Fluid --
      * Declares the viewhelper's parameters
      */
-    public function initializeArguments()
+    public function initializeArguments(): void
     {
         $this->registerArgument(
             'children',
@@ -43,26 +48,19 @@ class GetIdViewHelper extends OtAbstractViewHelper
      *  -- This method is expected by Fluid --
      * Renders the content as html
      *
-     * @param array $arguments
-     * @param Closure $renderChildrenClosure
-     * @param RenderingContextInterface $renderingContext
      * @return int|null
      */
-    public static function renderStatic(
-        array $arguments,
-        Closure $renderChildrenClosure,
-        RenderingContextInterface $renderingContext
-    ) {
+    public function render(): ?int
+    {
         $rootId = \Opentalent\OtTemplating\ViewHelpers\RootPage\GetIdViewHelper::renderStatic(
-            $arguments,
-            $renderChildrenClosure,
-            $renderingContext
+            $this->arguments,
+            $this->renderChildrenClosure,
+            $this->renderingContext
         );
-        $pageRepository = GeneralUtility::makeInstance(ObjectManager::class)->get(OtPageRepository::class);
 
-        $subpages = $pageRepository->getAllSubpagesForPage($rootId);
+        $subpages = $this->otPageRepository->getAllSubpagesForPage($rootId);
 
-        $templateName = $arguments['children'] == 1 ?
+        $templateName = $this->arguments['children'] == 1 ?
             'OpenTalent.OtTemplating->structuresEvents' :
             'OpenTalent.OtTemplating->events';
 

+ 12 - 16
ot_templating/Classes/ViewHelpers/GetPageUidViewHelper.php

@@ -6,6 +6,7 @@ namespace Opentalent\OtTemplating\ViewHelpers;
 use Closure;
 use Opentalent\OtCore\Website\OtPageRepository;
 use Opentalent\OtCore\ViewHelpers\OtAbstractViewHelper;
+use Opentalent\OtCore\Website\OtWebsiteRepository;
 use Opentalent\OtTemplating\ViewHelpers\RootPage\GetIdViewHelper;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 use TYPO3\CMS\Extbase\Object\ObjectManager;
@@ -25,12 +26,15 @@ use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper;
  */
 class GetPageUidViewHelper extends OtAbstractViewHelper
 {
+    public function __construct(
+        private readonly OtPageRepository $otPageRepository,
+    ) {}
 
     /**
      * -- This method is expected by Fluid --
      * Declares the viewhelper's parameters
      */
-    public function initializeArguments()
+    public function initializeArguments(): void
     {
         $this->registerArgument(
             'slug',
@@ -44,28 +48,20 @@ class GetPageUidViewHelper extends OtAbstractViewHelper
      * -- This method is expected by Fluid --
      * Renders the content as html
      *
-     * @param array $arguments
-     * @param Closure $renderChildrenClosure
-     * @param RenderingContextInterface $renderingContext
      * @return int|null
      */
-    public static function renderStatic(
-        array $arguments,
-        Closure $renderChildrenClosure,
-        RenderingContextInterface $renderingContext
-    ) {
+    public function render(): ?int
+    {
         $rootId = GetIdViewHelper::renderStatic(
-            $arguments,
-            $renderChildrenClosure,
-            $renderingContext
+            $this->arguments,
+            $this->renderChildrenClosure,
+            $this->renderingContext
         );
 
-        $pageRepository = GeneralUtility::makeInstance(ObjectManager::class)->get(OtPageRepository::class);
-
-        $subpages = $pageRepository->getAllSubpagesForPage($rootId);
+        $subpages = $this->otPageRepository->getAllSubpagesForPage($rootId);
 
         foreach ($subpages as $page) {
-            if ($page['slug'] === $arguments['slug']) {
+            if ($page['slug'] === $this->arguments['slug']) {
                 return $page['uid'];
             }
         }

+ 9 - 14
ot_templating/Classes/ViewHelpers/NewsPage/GetIdViewHelper.php

@@ -24,29 +24,24 @@ use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface;
  */
 class GetIdViewHelper extends OtAbstractViewHelper
 {
+    public function __construct(
+        private readonly OtPageRepository $otPageRepository,
+    ) {}
 
     /**
      *  -- This method is expected by Fluid --
      * Renders the content as html
      *
-     * @param array $arguments
-     * @param Closure $renderChildrenClosure
-     * @param RenderingContextInterface $renderingContext
      * @return int|null
      */
-    public static function renderStatic(
-        array $arguments,
-        Closure $renderChildrenClosure,
-        RenderingContextInterface $renderingContext
-    ) {
+    public function render(): ?int
+    {
         $rootId = \Opentalent\OtTemplating\ViewHelpers\RootPage\GetIdViewHelper::renderStatic(
-            $arguments,
-            $renderChildrenClosure,
-            $renderingContext
+            $this->arguments,
+            $this->renderChildrenClosure,
+            $this->renderingContext
         );
-        $pageRepository = GeneralUtility::makeInstance(ObjectManager::class)->get(OtPageRepository::class);
-
-        $subpages = $pageRepository->getAllSubpagesForPage($rootId);
+        $subpages = $this->otPageRepository->getAllSubpagesForPage($rootId);
 
         foreach ($subpages as $page) {
             if ($page['tx_fed_page_controller_action'] === 'OpenTalent.OtTemplating->news'

+ 10 - 15
ot_templating/Classes/ViewHelpers/Page/GetFirstWithTemplateViewHelper.php

@@ -6,6 +6,7 @@ namespace Opentalent\OtTemplating\ViewHelpers;
 use Closure;
 use Opentalent\OtCore\Website\OtPageRepository;
 use Opentalent\OtCore\ViewHelpers\OtAbstractViewHelper;
+use Opentalent\OtCore\Website\OtWebsiteRepository;
 use Opentalent\OtTemplating\ViewHelpers\RootPage\GetIdViewHelper;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 use TYPO3\CMS\Extbase\Object\ObjectManager;
@@ -22,6 +23,9 @@ use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface;
  */
 class FirstWithTemplateViewHelper extends OtAbstractViewHelper
 {
+    public function __construct(
+        private readonly OtPageRepository $otPageRepository,
+    ) {}
 
     /**
      * -- This method is expected by Fluid --
@@ -41,27 +45,18 @@ class FirstWithTemplateViewHelper extends OtAbstractViewHelper
      * -- This method is expected by Fluid --
      * Renders the content as html
      *
-     * @param array $arguments
-     * @param Closure $renderChildrenClosure
-     * @param RenderingContextInterface $renderingContext
      * @return int|null
      */
-    public static function renderStatic(
-        array $arguments,
-        Closure $renderChildrenClosure,
-        RenderingContextInterface $renderingContext
-    ) {
+    public function render() {
         $rootId = GetIdViewHelper::renderStatic(
-            $arguments,
-            $renderChildrenClosure,
-            $renderingContext
+            $this->arguments,
+            $this->renderChildrenClosure,
+            $this->renderingContext
         );
 
-        $pageRepository = GeneralUtility::makeInstance(ObjectManager::class)->get(OtPageRepository::class);
+        $subpages = $this->pageRepository->getAllSubpagesForPage($rootId);
 
-        $subpages = $pageRepository->getAllSubpagesForPage($rootId);
-
-        $templateName = 'OpenTalent.OtTemplating->' . $arguments['template'];
+        $templateName = 'OpenTalent.OtTemplating->' . $this->arguments['template'];
 
         foreach ($subpages as $page) {
             if ($page['tx_fed_page_controller_action'] === $templateName

+ 9 - 11
ot_templating/Classes/ViewHelpers/Request/GetWebsiteViewHelper.php

@@ -3,6 +3,7 @@
 namespace Opentalent\OtTemplating\ViewHelpers\Request;
 
 use Closure;
+use Opentalent\OtCore\Exception\NoSuchWebsiteException;
 use Opentalent\OtCore\ViewHelpers\OtAbstractViewHelper;
 use Opentalent\OtCore\Website\OtWebsiteRepository;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
@@ -19,22 +20,19 @@ use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface;
  * @package Opentalent\OtTemplating\ViewHelpers
  */
 class GetWebsiteViewHelper extends OtAbstractViewHelper {
+    public function __construct(
+        private readonly OtWebsiteRepository $otWebsiteRepository,
+    ) {}
 
     /**
      * -- This method is expected by Fluid --
      * Renders the content as html
      *
-     * @param array $arguments
-     * @param Closure $renderChildrenClosure
-     * @param RenderingContextInterface $renderingContext
-     * @return string|null
+     * @return array
+     * @throws NoSuchWebsiteException
      */
-    public static function renderStatic(
-        array $arguments,
-        Closure $renderChildrenClosure,
-        RenderingContextInterface $renderingContext
-    ) {
-        $pageRepository = GeneralUtility::makeInstance(ObjectManager::class)->get(OtWebsiteRepository::class);
-        return $pageRepository->getCurrentWebsiteFromFEGlobals();
+    public function render(): array
+    {
+        return $this->otWebsiteRepository->getCurrentWebsiteFromFEGlobals();
     }
 }

+ 9 - 10
ot_templating/Classes/ViewHelpers/RootPage/GetIdViewHelper.php

@@ -3,6 +3,7 @@
 namespace Opentalent\OtTemplating\ViewHelpers\RootPage;
 
 use Closure;
+use Opentalent\OtCore\Exception\NoSuchWebsiteException;
 use Opentalent\OtCore\ViewHelpers\OtAbstractViewHelper;
 use Opentalent\OtCore\Website\OtWebsiteRepository;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
@@ -21,21 +22,19 @@ use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface;
  */
 class GetIdViewHelper extends OtAbstractViewHelper
 {
+    public function __construct(
+        private readonly OtWebsiteRepository $otWebsiteRepository,
+    ) {}
+
     /**
      * -- This method is expected by Fluid --
      * Renders the content as html
      *
-     * @param array $arguments
-     * @param Closure $renderChildrenClosure
-     * @param RenderingContextInterface $renderingContext
      * @return int|null
+     * @throws NoSuchWebsiteException
      */
-    public static function renderStatic(
-        array $arguments,
-        Closure $renderChildrenClosure,
-        RenderingContextInterface $renderingContext
-    ) {
-        $pageRepository = GeneralUtility::makeInstance(ObjectManager::class)->get(OtWebsiteRepository::class);
-        return $pageRepository->getCurrentRootpageUidFromFEGlobals();
+    public function render(): ?int
+    {
+        return $this->otWebsiteRepository->getCurrentRootpageUidFromFEGlobals();
     }
 }

+ 11 - 10
ot_templating/Classes/ViewHelpers/RootPage/GetUriViewHelper.php

@@ -3,6 +3,8 @@
 namespace Opentalent\OtTemplating\ViewHelpers\RootPage;
 
 use Closure;
+use Opentalent\OtCore\Exception\InvalidWebsiteConfigurationException;
+use Opentalent\OtCore\Exception\NoSuchWebsiteException;
 use Opentalent\OtCore\ViewHelpers\OtAbstractViewHelper;
 use Opentalent\OtCore\Website\OtWebsiteRepository;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
@@ -21,21 +23,20 @@ use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface;
  */
 class GetUriViewHelper extends OtAbstractViewHelper
 {
+    public function __construct(
+        private readonly OtWebsiteRepository $otWebsiteRepository,
+    ) {}
+
     /**
      * -- This method is expected by Fluid --
      * Renders the content as html
      *
-     * @param array $arguments
-     * @param Closure $renderChildrenClosure
-     * @param RenderingContextInterface $renderingContext
      * @return string
+     * @throws InvalidWebsiteConfigurationException
+     * @throws NoSuchWebsiteException
      */
-    public static function renderStatic(
-        array $arguments,
-        Closure $renderChildrenClosure,
-        RenderingContextInterface $renderingContext
-    ) {
-        $pageRepository = GeneralUtility::makeInstance(ObjectManager::class)->get(OtWebsiteRepository::class);
-        return $pageRepository->getCurrentSiteRootUriFromFeGlobals();
+    public function render(): string
+    {
+        return $this->otWebsiteRepository->getCurrentSiteRootUriFromFeGlobals();
     }
 }

+ 11 - 12
ot_templating/Classes/ViewHelpers/Template/CurrentViewHelper.php

@@ -4,6 +4,7 @@ namespace Opentalent\OtTemplating\ViewHelpers\Template;
 
 
 use Closure;
+use Opentalent\OtCore\Exception\NoSuchWebsiteException;
 use Opentalent\OtCore\ViewHelpers\OtAbstractViewHelper;
 use Opentalent\OtCore\Website\OtWebsiteRepository;
 use Opentalent\OtTemplating\Templating\TemplateRepository;
@@ -22,24 +23,22 @@ use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface;
  */
 class CurrentViewHelper extends OtAbstractViewHelper
 {
+    public function __construct(
+        private readonly OtWebsiteRepository $otWebsiteRepository,
+        private readonly TemplateRepository $templateRepository,
+    ) {}
+
     /**
      * -- This method is expected by Fluid --
      * Renders the content as html
      *
-     * @param array $arguments
-     * @param Closure $renderChildrenClosure
-     * @param RenderingContextInterface $renderingContext
      * @return int|null
+     * @throws NoSuchWebsiteException
      */
-    public static function renderStatic(
-        array $arguments,
-        Closure $renderChildrenClosure,
-        RenderingContextInterface $renderingContext
-    ) {
-        $pageRepository = GeneralUtility::makeInstance(ObjectManager::class)->get(OtWebsiteRepository::class);
-        $website = $pageRepository->getCurrentWebsiteFromFEGlobals();
+    public function render(): ?int
+    {
+        $website = $this->otWebsiteRepository->getCurrentWebsiteFromFEGlobals();
 
-        $templateRepository = GeneralUtility::makeInstance(ObjectManager::class)->get(TemplateRepository::class);
-        return $templateRepository->getTemplate($website);
+        return $this->templateRepository->getTemplate($website);
     }
 }

+ 13 - 15
ot_templating/Classes/ViewHelpers/Template/GetPreferenceViewHelper.php

@@ -4,6 +4,7 @@ namespace Opentalent\OtTemplating\ViewHelpers\Template;
 
 
 use Closure;
+use Opentalent\OtCore\Exception\NoSuchWebsiteException;
 use Opentalent\OtCore\ViewHelpers\OtAbstractViewHelper;
 use Opentalent\OtCore\Website\OtWebsiteRepository;
 use Opentalent\OtTemplating\Templating\TemplateRepository;
@@ -22,6 +23,11 @@ use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface;
  */
 class GetPreferenceViewHelper extends OtAbstractViewHelper
 {
+    public function __construct(
+        private readonly OtWebsiteRepository $otWebsiteRepository,
+        private readonly TemplateRepository $templateRepository,
+    ) {}
+
     /**
      * -- This method is expected by Fluid --
      * Declares the viewhelper's parameters
@@ -40,23 +46,15 @@ class GetPreferenceViewHelper extends OtAbstractViewHelper
      * -- This method is expected by Fluid --
      * Renders the content as html
      *
-     * @param array $arguments
-     * @param Closure $renderChildrenClosure
-     * @param RenderingContextInterface $renderingContext
      * @return array
+     * @throws NoSuchWebsiteException
      */
-    public static function renderStatic(
-        array $arguments,
-        Closure $renderChildrenClosure,
-        RenderingContextInterface $renderingContext
-    ) {
-        $pageRepository = GeneralUtility::makeInstance(ObjectManager::class)->get(OtWebsiteRepository::class);
-        $website = $pageRepository->getCurrentWebsiteFromFEGlobals();
-
-        $templateRepository = GeneralUtility::makeInstance(ObjectManager::class)->get(TemplateRepository::class);
-        $preferences = $templateRepository->getTemplatePreferences($website);
-
-        $key = $arguments['key'];
+    public function render(): array
+    {
+        $website = $this->otWebsiteRepository->getCurrentWebsiteFromFEGlobals();
+        $preferences = $this->templateRepository->getTemplatePreferences($website);
+
+        $key = $this->arguments['key'];
         return $preferences[$key];
     }
 

+ 13 - 14
ot_templating/Classes/ViewHelpers/Template/GetPreferencesViewHelper.php

@@ -3,8 +3,10 @@
 namespace Opentalent\OtTemplating\ViewHelpers\Template;
 
 use Closure;
+use Opentalent\OtCore\Exception\NoSuchWebsiteException;
 use Opentalent\OtCore\Website\OtPageRepository;
 use Opentalent\OtCore\ViewHelpers\OtAbstractViewHelper;
+use Opentalent\OtCore\Website\OtWebsiteRepository;
 use Opentalent\OtTemplating\Templating\TemplateRepository;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 use TYPO3\CMS\Extbase\Object\ObjectManager;
@@ -19,27 +21,24 @@ use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface;
  *
  * @package Opentalent\OtTemplating\ViewHelpers\Template
  */
-class PreferencesViewHelper extends OtAbstractViewHelper
+class GetPreferencesViewHelper extends OtAbstractViewHelper
 {
+    public function __construct(
+        private readonly OtWebsiteRepository $otWebsiteRepository,
+        private readonly TemplateRepository $templateRepository,
+    ) {}
+
     /**
      * -- This method is expected by Fluid --
      * Renders the content as html
      *
-     * @param array $arguments
-     * @param Closure $renderChildrenClosure
-     * @param RenderingContextInterface $renderingContext
      * @return array
+     * @throws NoSuchWebsiteException
      */
-    public static function renderStatic(
-        array $arguments,
-        Closure $renderChildrenClosure,
-        RenderingContextInterface $renderingContext
-    ) {
-        $pageRepository = GeneralUtility::makeInstance(ObjectManager::class)->get(OtPageRepository::class);
-        $website = $pageRepository->getCurrentWebsiteFromFEGlobals();
-
-        $templateRepository = GeneralUtility::makeInstance(TemplateRepository::class);
-        return $templateRepository->getTemplatePreferences($website);
+    public function render(): array
+    {
+        $website = $this->otWebsiteRepository->getCurrentWebsiteFromFEGlobals();
+        return $this->templateRepository->getTemplatePreferences($website);
     }
 
 }

+ 24 - 4
ot_templating/Classes/XClass/Form/Configuration/ConfigurationManager.php

@@ -5,6 +5,7 @@ namespace Opentalent\OtTemplating\XClass\Form\Configuration;
 use Opentalent\OtCore\Exception\NoSuchWebsiteException;
 use Opentalent\OtCore\Website\OtPageRepository;
 use Opentalent\OtCore\Website\OtWebsiteRepository;
+use Opentalent\OtTemplating\Templating\TemplateRepository;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 use TYPO3\CMS\Extbase\Object\Exception;
 use TYPO3\CMS\Extbase\Object\ObjectManager;
@@ -12,6 +13,27 @@ use TYPO3\CMS\Form\Mvc\Configuration\Exception\ExtensionNameRequiredException;
 
 class ConfigurationManager extends \TYPO3\CMS\Form\Mvc\Configuration\ConfigurationManager
 {
+    private OtWebsiteRepository $otWebsiteRepository;
+    private OtPageRepository $otPageRepository;
+
+    /**
+     * @param OtWebsiteRepository $otWebsiteRepository
+     * @return void
+     */
+    public function injectOtWebsiteRepository(OtWebsiteRepository $otWebsiteRepository): void
+    {
+        $this->otWebsiteRepository = $otWebsiteRepository;
+    }
+
+    /**
+     * @param OtPageRepository $otPageRepository
+     * @return void
+     */
+    public function injectOtPageRepository(OtPageRepository $otPageRepository): void
+    {
+        $this->otPageRepository = $otPageRepository;
+    }
+
     /**
      * Override the default form configuration loader to add the forms directory matching
      * the current be user mounted organization(s) id(s)
@@ -26,11 +48,9 @@ class ConfigurationManager extends \TYPO3\CMS\Form\Mvc\Configuration\Configurati
     {
         $settings = parent::getConfigurationFromYamlFile($extensionName);
 
-        $otPageRepository = GeneralUtility::makeInstance(ObjectManager::class)->get(OtPageRepository::class);
-        foreach ($otPageRepository->getCurrentBeUserMountpoints() as $rootUid) {
+        foreach ($this->otPageRepository->getCurrentBeUserMountpoints() as $rootUid) {
 
-            $otWebsiteRepository = GeneralUtility::makeInstance(ObjectManager::class)->get(OtWebsiteRepository::class);
-            $website = $otWebsiteRepository->getWebsiteByPageUid($rootUid);
+            $website = $this->otWebsiteRepository->getWebsiteByPageUid($rootUid);
 
             if ($website['organization_id']) {
                 $settings['persistenceManager']['allowedFileMounts'][] = '1:/form_definitions/' . $website['organization_id'] . '/';