소스 검색

refactoring: update db structure and introduce ot_websites

Olivier Massot 4 년 전
부모
커밋
36cdd439c0
39개의 변경된 파일324개의 추가작업 그리고 198개의 파일을 삭제
  1. 2 1
      ot_connect/Classes/Service/OtAuthenticationService.php
  2. 1 1
      ot_core/Classes/Cache/OtCacheManager.php
  3. 1 1
      ot_core/Classes/Controller/ActionController.php
  4. 1 1
      ot_core/Classes/Controller/SelectedSiteController.php
  5. 1 0
      ot_core/Classes/Utility/FileUtility.php
  6. 14 0
      ot_core/Classes/Utility/RouteNormalizer.php
  7. 3 3
      ot_core/Classes/ViewHelpers/OtAbstractViewHelper.php
  8. 39 20
      ot_core/Classes/Website/OtPageRepository.php
  9. 105 0
      ot_core/Classes/Website/OtWebsiteRepository.php
  10. 3 17
      ot_core/Configuration/TCA/Overrides/pages.php
  11. 25 0
      ot_core/Configuration/base_site_conf.yaml
  12. 5 2
      ot_core/Resources/Private/Language/locallang.xlf
  13. 1 1
      ot_core/Tests/Unit/Controller/SelectedSiteControllerTest.php
  14. 1 1
      ot_core/Tests/Unit/Page/OtPageRepositoryTest.php
  15. 1 1
      ot_core/ext_localconf.php
  16. 11 7
      ot_core/ext_tables.sql
  17. 34 31
      ot_stats/Classes/Domain/Repository/MatomoWebsiteRepository.php
  18. 2 2
      ot_stats/Classes/Middleware/RequestHandler.php
  19. 8 24
      ot_stats/Classes/Settings/StatsSettingsRepository.php
  20. 2 2
      ot_stats/Classes/ViewHelpers/MatomoSiteIdViewHelper.php
  21. 2 2
      ot_stats/ext_tables.sql
  22. 15 20
      ot_templating/Classes/Controller/OtCustomizerController.php
  23. 1 1
      ot_templating/Classes/News/NewsFilter.php
  24. 3 3
      ot_templating/Classes/Page/ErrorHandler.php
  25. 15 29
      ot_templating/Classes/Templating/TemplateRepository.php
  26. 1 1
      ot_templating/Classes/ViewHelpers/Events/GetByIdViewHelper.php
  27. 1 1
      ot_templating/Classes/ViewHelpers/EventsPage/GetIdViewHelper.php
  28. 1 1
      ot_templating/Classes/ViewHelpers/GetPageUidViewHelper.php
  29. 1 2
      ot_templating/Classes/ViewHelpers/Members/GetAllCaViewHelper.php
  30. 2 3
      ot_templating/Classes/ViewHelpers/Members/GetAllViewHelper.php
  31. 1 3
      ot_templating/Classes/ViewHelpers/Members/GetPresidentViewHelper.php
  32. 1 1
      ot_templating/Classes/ViewHelpers/NewsPage/GetIdViewHelper.php
  33. 2 2
      ot_templating/Classes/ViewHelpers/RootPage/GetIdViewHelper.php
  34. 1 1
      ot_templating/Classes/ViewHelpers/RootPage/GetUriViewHelper.php
  35. 2 2
      ot_templating/Classes/ViewHelpers/Template/CurrentViewHelper.php
  36. 2 2
      ot_templating/Classes/ViewHelpers/Template/GetPreferenceViewHelper.php
  37. 2 2
      ot_templating/Classes/ViewHelpers/Template/GetPreferencesViewHelper.php
  38. 8 4
      ot_templating/Classes/XClass/Form/Configuration/ConfigurationManager.php
  39. 3 3
      ot_templating/ext_tables.sql

+ 2 - 1
ot_connect/Classes/Service/OtAuthenticationService.php

@@ -109,6 +109,7 @@ class OtAuthenticationService extends AbstractAuthenticationService
      * @see https://docs.typo3.org/m/typo3/reference-coreapi/master/en-us/ApiOverview/Authentication/Index.html#the-auth-services-api
      *
      * @return array|bool User record or false (content of fe_users/be_users as appropriate for the current mode)
+     * @throws GuzzleException
      */
     public function getUser()
     {
@@ -146,7 +147,7 @@ class OtAuthenticationService extends AbstractAuthenticationService
 
         // Request the latest data for the user and write it in the Typo3 DB
         //   * The shouldUserBeUpdated() method checks if the user was already
-        //   generated in the last minutes, to avoid unecessary operations *
+        //   generated in the last minutes, to avoid unnecessary operations *
         if ($this->shouldUserBeUpdated($username)) {
             $wasUpdated = $this->createOrUpdateUser();
             if (!$wasUpdated) {

+ 1 - 1
ot_core/Classes/Cache/OtCacheManager.php

@@ -2,7 +2,7 @@
 
 namespace Opentalent\OtCore\Cache;
 
-use Opentalent\OtCore\Page\OtPageRepository;
+use Opentalent\OtCore\Website\OtPageRepository;
 use TYPO3\CMS\Core\Service\OpcodeCacheService;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 use TYPO3\CMS\Extbase\Object\ObjectManager;

+ 1 - 1
ot_core/Classes/Controller/ActionController.php

@@ -2,7 +2,7 @@
 
 namespace Opentalent\OtCore\Controller;
 
-use Opentalent\OtCore\Page\OtPageRepository;
+use Opentalent\OtCore\Website\OtPageRepository;
 
 /**
  * Base class for all controllers of backend modules

+ 1 - 1
ot_core/Classes/Controller/SelectedSiteController.php

@@ -3,7 +3,7 @@
 namespace Opentalent\OtCore\Controller;
 
 use Opentalent\OtCore\Exception\NoSiteSelected;
-use Opentalent\OtCore\Page\OtPageRepository;
+use Opentalent\OtCore\Website\OtPageRepository;
 use TYPO3\CMS\Extbase\Object\ObjectManager;
 
 /**

+ 1 - 0
ot_core/Classes/Utility/FileUtility.php

@@ -9,6 +9,7 @@ class FileUtility
      * Else, does a simple rmdir($dir)
      *
      * @param $dir
+     * @param bool $recursive
      */
     public static function rmdir($dir, $recursive=false) {
         if (!$recursive) {

+ 14 - 0
ot_core/Classes/Utility/RouteNormalizer.php

@@ -0,0 +1,14 @@
+<?php
+
+namespace Opentalent\OtCore\Utility;
+
+class RouteNormalizer
+{
+    public static function normalizeSlug(string $slug) {
+        return '/' . trim($slug, '/');
+    }
+
+    public static function normalizeDomain(string $domain) {
+        return preg_replace('/https?:\/\/([\w\.]+)(?:\/.*)?/', '$1', $domain);
+    }
+}

+ 3 - 3
ot_core/Classes/ViewHelpers/OtAbstractViewHelper.php

@@ -3,7 +3,7 @@
 namespace Opentalent\OtCore\ViewHelpers;
 
 use FluidTYPO3\Vhs\Utility\ErrorUtility;
-use Opentalent\OtCore\Page\OtPageRepository;
+use Opentalent\OtCore\Website\OtPageRepository;
 use Psr\Log\LoggerAwareInterface;
 use Psr\Log\LoggerAwareTrait;
 use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper;
@@ -21,7 +21,7 @@ class OtAbstractViewHelper  extends AbstractViewHelper implements LoggerAwareInt
      * @var OtPageRepository
      *
      */
-    protected $pageRepository;
+    protected OtPageRepository $pageRepository;
 
     /**
      * Throw a VHS viewhelper error
@@ -43,7 +43,7 @@ class OtAbstractViewHelper  extends AbstractViewHelper implements LoggerAwareInt
      *
      * @return \TYPO3\CMS\Core\Localization\LanguageService
      */
-    protected function getLanguageService()
+    protected function getLanguageService(): \TYPO3\CMS\Core\Localization\LanguageService
     {
         return $GLOBALS['LANG'];
     }

+ 39 - 20
ot_core/Classes/Page/OtPageRepository.php → ot_core/Classes/Website/OtPageRepository.php

@@ -1,6 +1,6 @@
 <?php
 
-namespace Opentalent\OtCore\Page;
+namespace Opentalent\OtCore\Website;
 
 use Opentalent\OtCore\Exception\NoSiteSelected;
 use TYPO3\CMS\Core\Site\Entity\Site;
@@ -18,17 +18,22 @@ class OtPageRepository
     /**
      * @var \FluidTYPO3\Vhs\Service\PageService
      */
-    private $pageService;
+    private \FluidTYPO3\Vhs\Service\PageService $pageService;
 
     /**
      * @var \TYPO3\CMS\Frontend\Page\PageRepository
      */
-    private $pageRepository;
+    private \TYPO3\CMS\Frontend\Page\PageRepository $pageRepository;
 
     /**
      * @var \TYPO3\CMS\Core\Database\ConnectionPool
      */
-    private $connectionPool;
+    private \TYPO3\CMS\Core\Database\ConnectionPool $connectionPool;
+
+    /**
+     * @var \TYPO3\CMS\Core\Site\SiteFinder
+     */
+    private \TYPO3\CMS\Core\Site\SiteFinder $siteFinder;
 
     public function injectPageService(\FluidTYPO3\Vhs\Service\PageService $pageService)
     {
@@ -57,7 +62,8 @@ class OtPageRepository
      * @param bool $withRestrictions Set to true to add the standard restrictions (deleted, forbidden...etc.)
      * @return array
      */
-    public function getPagesByPid($pid, bool $withRestrictions=false) {
+    public function getPagesByPid(int $pid, bool $withRestrictions=false): array
+    {
         $queryBuilder = $this->connectionPool->getQueryBuilderForTable('pages');
         if (!$withRestrictions) {
             $queryBuilder->getRestrictions()->removeAll();
@@ -79,7 +85,8 @@ class OtPageRepository
      *
      * @return array
      */
-    public function getRootPageFor($pageUid) {
+    public function getRootPageFor($pageUid): array
+    {
         $rootLine = $this->pageService->getRootLine($pageUid);
 
         for (end($rootLine); key($rootLine)!==null; prev($rootLine)){
@@ -99,7 +106,8 @@ class OtPageRepository
      * @param bool $withRestrictions Set to true to add the standard restrictions (deleted, forbidden...etc.)
      * @return array
      */
-    public function getAllSubpagesForPage(int $pageUid, bool $withRestrictions=false) {
+    public function getAllSubpagesForPage(int $pageUid, bool $withRestrictions=false): array
+    {
         $subpages = [];
 
         $stack = $this->getPagesByPid($pageUid, $withRestrictions);
@@ -131,8 +139,10 @@ class OtPageRepository
      *
      * @param int $pageUid
      * @return Site
+     * @throws \TYPO3\CMS\Core\Exception\SiteNotFoundException
      */
-    public function getSiteFor(int $pageUid) {
+    public function getSiteFor(int $pageUid): Site
+    {
         $rootPage = $this->getRootPageFor($pageUid);
         $rootUid = $rootPage['uid'];
 
@@ -143,8 +153,10 @@ class OtPageRepository
      * Returns the typo3 site matching the current request (FE only)
      *
      * @return Site
+     * @throws \TYPO3\CMS\Core\Exception\SiteNotFoundException
      */
-    public function getCurrentSite() {
+    public function getCurrentSite(): Site
+    {
         $request = $GLOBALS['TYPO3_REQUEST'];
         $site = $request->getAttribute('site');
         return $this->siteFinder->getSiteByIdentifier($site->getIdentifier());
@@ -154,8 +166,10 @@ class OtPageRepository
      * Returns the current site's rootpage uid (FE only)
      *
      * @return int
+     * @throws \TYPO3\CMS\Core\Exception\SiteNotFoundException
      */
-    public function getCurrentSiteRootPageId() {
+    public function getCurrentSiteRootPageUid(): int
+    {
         $site = $this->getCurrentSite();
         return $site->getRootPageId();
     }
@@ -163,9 +177,11 @@ class OtPageRepository
     /**
      * Returns the current site's rootpage URI (FE only)
      *
-     * @return string
+     * @return \Psr\Http\Message\UriInterface
+     * @throws \TYPO3\CMS\Core\Exception\SiteNotFoundException
      */
-    public function getCurrentSiteRootPageUri() {
+    public function getCurrentSiteRootPageUri(): \Psr\Http\Message\UriInterface
+    {
         $site = $this->getCurrentSite();
         return $site->getBase();
     }
@@ -175,9 +191,11 @@ class OtPageRepository
      * Returns the current site's rootpage array
      *
      * @return array
+     * @throws \TYPO3\CMS\Core\Exception\SiteNotFoundException
      */
-    public function getCurrentSiteRootPage() {
-        $uid = $this->getCurrentSiteRootPageUri();
+    public function getCurrentSiteRootPage(): array
+    {
+        $uid = $this->getCurrentSiteRootPageUid();
         return $this->pageRepository->getPage($uid);
     }
 
@@ -187,7 +205,8 @@ class OtPageRepository
      *
      * @return int|null
      */
-    public function getCurrentPageId() {
+    public function getCurrentPageId(): ?int
+    {
         return (int)GeneralUtility::_GP('id');
     }
 
@@ -199,7 +218,8 @@ class OtPageRepository
      * @return int
      * @throws NoSiteSelected
      */
-    public function getCurrentRootUid() {
+    public function getCurrentRootUid(): int
+    {
         $pageUid = $this->getCurrentPageId();
 
         $rootPage = $this->getRootPageFor($pageUid);
@@ -225,12 +245,11 @@ class OtPageRepository
         }
 
         $mountpoints = $be_user->returnWebmounts();
-        $mountpoints = array_filter($mountpoints, function($m) { return is_numeric($m) && (int)$m > 0; });
-
-        return $mountpoints;
+        return array_filter($mountpoints, function($m) { return is_numeric($m) && (int)$m > 0; });;
     }
 
-    public function getPage(int $uid) {
+    public function getPage(int $uid): array
+    {
         return $this->pageRepository->getPage($uid, true);
     }
 }

+ 105 - 0
ot_core/Classes/Website/OtWebsiteRepository.php

@@ -0,0 +1,105 @@
+<?php
+
+namespace Opentalent\OtCore\Website;
+
+use TYPO3\CMS\Extbase\Persistence\Generic\Qom\Join;
+
+class OtWebsiteRepository
+{
+    /**
+     * @var \TYPO3\CMS\Core\Database\ConnectionPool
+     */
+    private \TYPO3\CMS\Core\Database\ConnectionPool $connectionPool;
+
+    public function injectConnectionPool(\TYPO3\CMS\Core\Database\ConnectionPool $connectionPool)
+    {
+        $this->connectionPool = $connectionPool;
+    }
+
+    public function getWebsiteByUid(int $uid, bool $withRestrictions = true): array
+    {
+        $queryBuilder = $this->connectionPool->getQueryBuilderForTable('ot_websites');
+        if (!$withRestrictions) {
+            $queryBuilder->getRestrictions()->removeAll();
+        }
+        return $queryBuilder
+            ->select('*')
+            ->from('ot_websites')
+            ->where($queryBuilder->expr()->eq('uid', $uid))
+            ->execute()
+            ->fetch();
+    }
+
+    public function getWebsiteByOrganizationId(int $organizationId, bool $withRestrictions = true): array
+    {
+        $queryBuilder = $this->connectionPool->getQueryBuilderForTable('ot_websites');
+        if (!$withRestrictions) {
+            $queryBuilder->getRestrictions()->removeAll();
+        }
+        return $queryBuilder
+            ->select('*')
+            ->from('ot_websites')
+            ->where($queryBuilder->expr()->eq('organization_id', $organizationId))
+            ->execute()
+            ->fetch();
+    }
+
+    public function getWebsiteByPageUid(int $pageUid, bool $withRestrictions = true): array
+    {
+        $queryBuilder = $this->connectionPool->getQueryBuilderForTable('pages');
+        if (!$withRestrictions) {
+            $queryBuilder->getRestrictions()->removeAll();
+        }
+        return $queryBuilder
+            ->select('w.*')
+            ->from('ot_websites', 'w')
+            ->innerJoin('w', 'pages', 'p', $queryBuilder->expr()->eq('p.ot_website_uid', 'w.uid'))
+            ->where($queryBuilder->expr()->eq('p.uid', $pageUid))
+            ->execute()
+            ->fetch();
+    }
+
+    public function getWebsiteRootUid(int $websiteUid, bool $withRestrictions = true): array {
+        $queryBuilder = $this->connectionPool->getQueryBuilderForTable('ot_websites');
+        if (!$withRestrictions) {
+            $queryBuilder->getRestrictions()->removeAll();
+        }
+        return $queryBuilder
+            ->select('uid')
+            ->from('pages')
+            ->where($queryBuilder->expr()->eq('ot_website_uid', $websiteUid))
+            ->andWhere($queryBuilder->expr()->eq('is_siteroot', 1))
+            ->execute()
+            ->fetchColumn(0);
+    }
+
+    /**
+     * Retrieves the current full domain of the given website.
+     *
+     * @param int $websiteUid
+     * @return string
+     */
+    public function getWebsiteDomain(int $websiteUid): string
+    {
+        $website = $this->getWebsiteByUid($websiteUid);
+
+        if ($website['custom_domain']) {
+            return $website['custom_domain'];
+        }
+
+        return $website['subdomain'] . '.opentalent.fr';
+    }
+
+    public function getWebsiteBaseUri(int $websiteUid): string
+    {
+        return 'https://' . $this->getWebsiteDomain($websiteUid);
+    }
+
+    public function getWebsiteConfiguration(int $rootUid, string $domain): array {
+        return [
+        ];
+    }
+
+
+
+}

+ 3 - 17
ot_core/Configuration/TCA/Overrides/pages.php

@@ -3,15 +3,8 @@ defined('TYPO3_MODE') or die();
 
 // ** Add fields to the backend
 $columns = array (
-    'tx_opentalent_structure_id' => array (
-        'label' => 'LLL:EXT:ot_core/Resources/Private/Language/locallang.xlf:structure_id',
-        'displayCond' => 'HIDE_FOR_NON_ADMINS',
-        'config' => array (
-            'type' => 'input',
-        )
-    ),
-    'tx_opentalent_structure_domain' => array (
-        'label' => 'LLL:EXT:ot_core/Resources/Private/Language/locallang.xlf:structure_id',
+    'ot_website_uid' => array (
+        'label' => 'LLL:EXT:ot_core/Resources/Private/Language/locallang.xlf:website_uid',
         'displayCond' => 'HIDE_FOR_NON_ADMINS',
         'config' => array (
             'type' => 'input',
@@ -26,14 +19,7 @@ $columns = array (
 
 \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addToAllTCAtypes(
     'pages',
-    'tx_opentalent_structure_id',
+    'ot_website_uid',
     '',
     'after:subtitle'
 );
-
-\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addToAllTCAtypes(
-    'pages',
-    'tx_opentalent_structure_domain',
-    '',
-    'after:tx_opentalent_structure_id'
-);

+ 25 - 0
ot_core/Configuration/base_site_conf.yaml

@@ -0,0 +1,25 @@
+errorHandling:
+  -
+    errorCode: '404'
+    errorHandler: PHP
+    errorPhpClassFQCN: Opentalent\OtTemplating\Page\ErrorHandler
+  -
+    errorCode: '403'
+    errorHandler: PHP
+    errorPhpClassFQCN: Opentalent\OtTemplating\Page\ErrorHandler
+flux_content_types: ''
+flux_page_templates: ''
+languages:
+  -
+    title: Fr
+    enabled: true
+    base: /
+    typo3Language: fr
+    locale: fr_FR
+    iso-639-1: fr
+    navigationTitle: Fr
+    hreflang: fr-FR
+    direction: ltr
+    flag: fr
+    languageId: '0'
+routes: {  }

+ 5 - 2
ot_core/Resources/Private/Language/locallang.xlf

@@ -13,8 +13,11 @@
 			<trans-unit id="structure_id">
 				<source>Id de la structure</source>
 			</trans-unit>
-			<trans-unit id="structure_domain">
-				<source>Domaine de la structure</source>
+			<trans-unit id="structure_subdomain">
+				<source>Sous-domaine de la structure</source>
+			</trans-unit>
+			<trans-unit id="website_uid">
+				<source>Website Uid</source>
 			</trans-unit>
 		</body>
 	</file>

+ 1 - 1
ot_core/Tests/Unit/Controller/SelectedSiteControllerTest.php

@@ -5,7 +5,7 @@ namespace Opentalent\OtCore\Tests\Unit\Controller;
 use Nimut\TestingFramework\TestCase\UnitTestCase;
 use Opentalent\OtCore\Controller\SelectedSiteController;
 use Opentalent\OtCore\Exception\NoSiteSelected;
-use Opentalent\OtCore\Page\OtPageRepository;
+use Opentalent\OtCore\Website\OtPageRepository;
 
 class SelectedSiteControllerTest extends UnitTestCase
 {

+ 1 - 1
ot_core/Tests/Unit/Page/OtPageRepositoryTest.php

@@ -2,7 +2,7 @@
 
 namespace Opentalent\OtCore\Tests\Unit\Page;
 
-use Opentalent\OtCore\Page\OtPageRepository;
+use Opentalent\OtCore\Website\OtPageRepository;
 use Nimut\TestingFramework\TestCase\UnitTestCase;
 use Opentalent\OtCore\Tests\Unit\Fixtures\PageFixtures;
 use Opentalent\OtCore\Tests\Unit\QueryBuilderProphet;

+ 1 - 1
ot_core/ext_localconf.php

@@ -16,7 +16,7 @@ $GLOBALS['TYPO3_CONF_VARS']['LOG']['Opentalent']['OtCore']['writerConfiguration'
     TYPO3\CMS\Core\Log\LogLevel::WARNING => [
         // add a DatabaseWriter
         TYPO3\CMS\Core\Log\Writer\DatabaseWriter::class => [
-            'logTable' => 'tx_opentalent_log'
+            'logTable' => 'ot_log'
         ]
     ]
 ];

+ 11 - 7
ot_core/ext_tables.sql

@@ -4,24 +4,28 @@
 # Table structure for table 'pages'
 #
 CREATE TABLE pages (
-	tx_opentalent_structure_id bigint,
-	tx_opentalent_structure_domain varchar(255)
+	ot_website_uid INT UNSIGNED DEFAULT NULL
 );
 
 #
-# Table structure for table 'tx_opentalent_custom_domains'
+# Table structure for table 'ot_websites'
 #
-CREATE TABLE tx_opentalent_custom_domains
+CREATE TABLE ot_websites
 (
-    uid INT UNSIGNED NOT NULL,
+    uid INT UNSIGNED NOT NULL AUTO_INCREMENT,
     organization_id INT NOT NULL,
-    domain VARCHAR(2048) NOT NULL
+    organization_name VARCHAR(255) NOT NULL,
+    subdomain VARCHAR(255) NOT NULL,
+    custom_domain VARCHAR(255),
+    deleted tinyint(1) unsigned DEFAULT '0' NOT NULL,
+    locale VARCHAR(10) DEFAULT 'fr-FR',
+    PRIMARY KEY (uid)
 );
 
 #
 # Table structure for table 'tx_opentalent_log'
 #
-CREATE TABLE tx_opentalent_log (
+CREATE TABLE ot_log (
     request_id varchar(13) DEFAULT '' NOT NULL,
     time_micro double(16,4) NOT NULL default '0.0000',
     component varchar(255) DEFAULT '' NOT NULL,

+ 34 - 31
ot_stats/Classes/Domain/Repository/MatomoWebsiteRepository.php

@@ -2,7 +2,8 @@
 
 namespace Opentalent\OtStats\Domain\Repository;
 
-use Opentalent\OtCore\Page\OtPageRepository;
+use Opentalent\OtCore\Website\OtPageRepository;
+use Opentalent\OtCore\Website\OtWebsiteRepository;
 use Opentalent\OtStats\Domain\Model\MatomoWebsite;
 use PDO;
 use TYPO3\CMS\Core\Database\ConnectionPool;
@@ -30,12 +31,12 @@ class MatomoWebsiteRepository
      *
      * @var PDO
      */
-    private $matomoCnn;
+    private PDO $matomoCnn;
 
     /**
      * @var \TYPO3\CMS\Core\Database\ConnectionPool
      */
-    private $connectionPool;
+    private ConnectionPool $connectionPool;
 
     public function injectConnectionPool(\TYPO3\CMS\Core\Database\ConnectionPool $connectionPool)
     {
@@ -60,7 +61,8 @@ class MatomoWebsiteRepository
      * @param array $data
      * @return MatomoWebsite
      */
-    private function fromArray(array $data) {
+    private function fromArray(array $data): MatomoWebsite
+    {
         $matomoSite = new MatomoWebsite();
         $matomoSite->setId($data['idsite']);
         $matomoSite->setName($data['name']);
@@ -77,7 +79,8 @@ class MatomoWebsiteRepository
      * @param int $id
      * @return MatomoWebsite|null
      */
-    public function findById(int $id) {
+    public function findById(int $id): ?MatomoWebsite
+    {
         $stmt = $this->matomoCnn->prepare(
             "SELECT s.idsite, s.name, s.main_url, s.excluded_ips, s.type, s.creator_login
                       FROM matomo.matomo_site s
@@ -98,7 +101,8 @@ class MatomoWebsiteRepository
      * @param string $uri
      * @return MatomoWebsite|null
      */
-    public function findByUri(string $uri) {
+    public function findByUri(string $uri): ?MatomoWebsite
+    {
         $stmt = $this->matomoCnn->prepare(
             "SELECT s.idsite, s.name, s.main_url, s.excluded_ips, s.type, s.creator_login
                       FROM matomo.matomo_site s
@@ -120,16 +124,17 @@ class MatomoWebsiteRepository
      * @param int $rootUid
      * @return MatomoWebsite|null
      */
-    public function findByRootUid(int $rootUid) {
-        $otPageRepository = GeneralUtility::makeInstance(ObjectManager::class)->get(OtPageRepository::class);
+    public function findByRootUid(int $rootUid): ?MatomoWebsite
+    {
+        $otWebsiteRepository = GeneralUtility::makeInstance(ObjectManager::class)->get(OtWebsiteRepository::class);
 
         // Just to make sure this page is actually the root page
-        $rootPage = $otPageRepository->getRootPageFor($rootUid);
+        $website = $otWebsiteRepository->getWebsiteByPageUid($rootUid);
 
-        if ($rootPage['tx_opentalent_matomo_id'] == null) {
+        if ($website['matomo_site_id'] == null) {
             return null;
         }
-        return $this->findById($rootPage['tx_opentalent_matomo_id']);
+        return $this->findById($website['matomo_site_id']);
     }
 
     /**
@@ -147,23 +152,21 @@ class MatomoWebsiteRepository
         $rootPage = $otPageRepository->getRootPageFor($rootUid);
         $rootUid = $rootPage['uid'];
 
+        $otWebsiteRepository = GeneralUtility::makeInstance(ObjectManager::class)->get(OtWebsiteRepository::class);
+        $website = $otWebsiteRepository->getWebsiteByUid($rootPage['ot_website_uid']);
+
         // Retrieve current site informations
         $isDev = ($_SERVER['TYPO3_CONTEXT'] == 'Development');
 
-        $site = $otPageRepository->getSiteFor($rootUid);
-        $title = $site->getIdentifier();
+        $title = $website['subdomain'];
         if ($isDev) {
             $title = $title . "_DEV";
         }
 
-        $uri = $site->getBase();
-        if ($isDev && preg_match(self::RELATIVE_PATH_VALIDATION, $uri)) {
-            $host = $_SERVER['HTTP_HOST'];
-            $uri = $host . $uri;
-        }
-
-        if (!preg_match('/https?:\/\/.*/', $uri)) {
-            $uri = 'https://' . $uri;
+        if ($isDev) {
+            $uri = rtrim($_SERVER['HTTP_HOST'], '/') . '/' . $website['subdomain'];
+        } else {
+            $uri = $otWebsiteRepository->getWebsiteDomain($website['uid']);
         }
 
         if (!preg_match(self::DOMAIN_VALIDATION, $uri)) {
@@ -171,10 +174,10 @@ class MatomoWebsiteRepository
         }
 
         // Make sure the current typo3 website has no existing configured matomo website
-        if ($rootPage['tx_opentalent_matomo_id'] != null) {
+        if ($website['matomo_site_id'] != null) {
             // Check if the registered matomo site still exist. If it does, throw an error.
-            if ($this->findById($rootPage['tx_opentalent_matomo_id']) != null) {
-                throw new \RuntimeException('This website has already been registered (matomo id: ' . $rootPage['tx_opentalent_matomo_id'] . ')');
+            if ($this->findById($website['matomo_site_id']) != null) {
+                throw new \RuntimeException('This website has already been registered (matomo id: ' . $website['matomo_site_id'] . ')');
             }
         }
 
@@ -217,11 +220,11 @@ class MatomoWebsiteRepository
             }
 
             // Update typo3 DB
-            $queryBuilder = $this->connectionPool->getQueryBuilderForTable('pages');
+            $queryBuilder = $this->connectionPool->getQueryBuilderForTable('ot_websites');
             $queryBuilder
-                ->update('pages')
-                ->where($queryBuilder->expr()->eq('uid', $rootUid))
-                ->set('tx_opentalent_matomo_id', $matomoSiteId)
+                ->update('ot_websites')
+                ->where($queryBuilder->expr()->eq('uid', $website['uid']))
+                ->set('matomo_site_id', $matomoSiteId)
                 ->execute();
 
             // finalize
@@ -258,9 +261,9 @@ class MatomoWebsiteRepository
             // Update typo3 DB
             $queryBuilder = $this->connectionPool->getQueryBuilderForTable('pages');
             $queryBuilder
-                ->update('pages')
-                ->where($queryBuilder->expr()->eq('uid', $rootUid))
-                ->set('tx_opentalent_matomo_id', null)
+                ->update('ot_websites')
+                ->where($queryBuilder->expr()->eq('matomo_site_id', $matomoSite->getId()))
+                ->set('matomo_site_id', null)
                 ->execute();
 
             // finalize

+ 2 - 2
ot_stats/Classes/Middleware/RequestHandler.php

@@ -1,7 +1,7 @@
 <?php
 namespace Opentalent\OtStats\Middleware;
 
-use Opentalent\OtCore\Page\OtPageRepository;
+use Opentalent\OtCore\Website\OtPageRepository;
 use Opentalent\OtStats\Settings\StatsSettingsRepository;
 use Psr\Http\Message\ResponseInterface;
 use Psr\Http\Message\ServerRequestInterface;
@@ -38,7 +38,7 @@ class RequestHandler implements MiddlewareInterface
 
         // Retrieve the current matomo site's id if set
         $otPageRepository = GeneralUtility::makeInstance(ObjectManager::class)->get(OtPageRepository::class);
-        $rootPageUid = $otPageRepository->getCurrentSiteRootPageId();
+        $rootPageUid = $otPageRepository->getCurrentSiteRootPageUid();
 
         $statsSettingsRepository = GeneralUtility::makeInstance(ObjectManager::class)->get(StatsSettingsRepository::class);
         $matomoSiteId = $statsSettingsRepository->getMatomoSiteId($rootPageUid);

+ 8 - 24
ot_stats/Classes/Settings/StatsSettingsRepository.php

@@ -2,6 +2,10 @@
 
 namespace Opentalent\OtStats\Settings;
 
+use Opentalent\OtCore\Website\OtWebsiteRepository;
+use TYPO3\CMS\Core\Utility\GeneralUtility;
+use TYPO3\CMS\Extbase\Object\ObjectManager;
+
 /**
  * Class StatsRepository
  *
@@ -11,35 +15,15 @@ namespace Opentalent\OtStats\Settings;
  */
 class StatsSettingsRepository
 {
-    /**
-     * @var \TYPO3\CMS\Core\Database\ConnectionPool
-     */
-    private $connectionPool;
-
-    public function injectConnectionPool(\TYPO3\CMS\Core\Database\ConnectionPool $connectionPool)
-    {
-        $this->connectionPool = $connectionPool;
-    }
-
     /**
      * Returns the website registered matomo site's id
      * @param int $rootPageUid
      * @return int|null
      */
-    public function getMatomoSiteId(int $rootPageUid)
+    public function getMatomoSiteId(int $rootPageUid): ?int
     {
-        // Set up a connection to the typo3 DB
-        $queryBuilder = $this->connectionPool->getQueryBuilderForTable('pages');
-        $matomoId = $queryBuilder
-                        ->select('tx_opentalent_matomo_id')
-                        ->from('pages')
-                        ->where($queryBuilder->expr()->eq('uid', $rootPageUid))
-                        ->andWhere($queryBuilder->expr()->eq('is_siteroot', 1))
-                        ->execute()
-                        ->fetchColumn(0);
-        if ($matomoId === false) {
-            throw new \RuntimeException('No existing root page with uid ' . $rootPageUid);
-        }
-        return $matomoId;
+        $otWebsiteRepository = GeneralUtility::makeInstance(ObjectManager::class)->get(OtWebsiteRepository::class);
+        $website = $otWebsiteRepository->getWebsiteByPageUid($rootPageUid);
+        return $website['matomo_site_id'];
     }
 }

+ 2 - 2
ot_stats/Classes/ViewHelpers/MatomoSiteIdViewHelper.php

@@ -4,7 +4,7 @@ namespace Opentalent\OtStats\ViewHelpers;
 
 
 use Closure;
-use Opentalent\OtCore\Page\OtPageRepository;
+use Opentalent\OtCore\Website\OtPageRepository;
 use Opentalent\OtStats\Settings\StatsSettingsRepository;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 use TYPO3\CMS\Extbase\Object\ObjectManager;
@@ -38,7 +38,7 @@ class MatomoSiteIdViewHelper extends AbstractViewHelper
         RenderingContextInterface $renderingContext
     ) {
         $otPageRepository = GeneralUtility::makeInstance(ObjectManager::class)->get(OtPageRepository::class);
-        $rootPageUid = $otPageRepository->getCurrentSiteRootPageId();
+        $rootPageUid = $otPageRepository->getCurrentSiteRootPageUid();
 
         $statsSettingsRepository = GeneralUtility::makeInstance(ObjectManager::class)->get(StatsSettingsRepository::class);
         return $statsSettingsRepository->getMatomoSiteId($rootPageUid);

+ 2 - 2
ot_stats/ext_tables.sql

@@ -3,6 +3,6 @@
 #
 # Table structure for table 'pages'
 #
-CREATE TABLE pages (
-    tx_opentalent_matomo_id bigint
+CREATE TABLE ot_websites (
+    matomo_site_id bigint
 );

+ 15 - 20
ot_templating/Classes/Controller/OtCustomizerController.php

@@ -4,6 +4,7 @@ namespace Opentalent\OtTemplating\Controller;
 
 use Opentalent\OtCore\Controller\SelectedSiteController;
 use Opentalent\OtCore\Cache\OtCacheManager;
+use Opentalent\OtCore\Website\OtWebsiteRepository;
 use Opentalent\OtTemplating\Templating\TemplateRepository;
 use PDO;
 use TYPO3\CMS\Core\Database\ConnectionPool;
@@ -42,23 +43,19 @@ class OtCustomizerController extends SelectedSiteController {
 
     /**
      * A template has been selected, apply the change
-     *
      */
     public function selectTemplateAction() {
         $templateKey = $this->request->getArgument('template_key');
 
+        $otWebsiteRepository = GeneralUtility::makeInstance(ObjectManager::class)->get(OtWebsiteRepository::class);
+        $website = $otWebsiteRepository->getWebsiteByPageUid($this->currentRootUid);
+
         // applies the change in the database
         $queryBuilder = $this->connectionPool->getQueryBuilderForTable('pages');
-        $queryBuilder->update('pages')
-            ->where(
-                $queryBuilder->expr()->eq(
-                    'uid',
-                    $queryBuilder->createNamedParameter($this->currentRootUid, PDO::PARAM_INT)
-                )
-            )
-            ->set('tx_opentalent_template', $templateKey)
-            ->execute()
-        ;
+        $queryBuilder->update('ot_websites')
+            ->where($queryBuilder->expr()->eq('uid', $website['uid']))
+            ->set('template', $templateKey)
+            ->execute();
 
         // Clear the site's cache
         OtCacheManager::clearSiteCache($this->currentRootUid);
@@ -89,15 +86,13 @@ class OtCustomizerController extends SelectedSiteController {
         }
 
         // applies the change in the database
-        $queryBuilder = $this->connectionPool->getQueryBuilderForTable('pages');
-        $queryBuilder->update('pages')
-            ->where(
-                $queryBuilder->expr()->eq(
-                    'uid',
-                    $queryBuilder->createNamedParameter($this->currentRootUid, PDO::PARAM_INT)
-                )
-            )
-            ->set('tx_opentalent_template_preferences', json_encode($prefs))
+        $otWebsiteRepository = GeneralUtility::makeInstance(ObjectManager::class)->get(OtWebsiteRepository::class);
+        $website = $otWebsiteRepository->getWebsiteByPageUid($this->currentRootUid);
+
+        $queryBuilder = $this->connectionPool->getQueryBuilderForTable('ot_websites');
+        $queryBuilder->update('ot_websites')
+            ->where($queryBuilder->expr()->eq('uid', $website['uid']))
+            ->set('template_preferences', json_encode($prefs))
             ->execute();
 
         // Clear the site's cache

+ 1 - 1
ot_templating/Classes/News/NewsFilter.php

@@ -3,7 +3,7 @@
 namespace Opentalent\OtTemplating\News;
 
 use GeorgRinger\News\Utility\Page;
-use Opentalent\OtCore\Page\OtPageRepository;
+use Opentalent\OtCore\Website\OtPageRepository;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 use TYPO3\CMS\Extbase\Object\ObjectManager;
 

+ 3 - 3
ot_templating/Classes/Page/ErrorHandler.php

@@ -2,7 +2,7 @@
 
 namespace Opentalent\OtTemplating\Page;
 
-use Opentalent\OtCore\Page\OtPageRepository;
+use Opentalent\OtCore\Website\OtPageRepository;
 use Psr\Http\Message\ResponseInterface;
 use Psr\Http\Message\ServerRequestInterface;
 use TYPO3\CMS\Core\Error\PageErrorHandler\PageContentErrorHandler;
@@ -34,13 +34,13 @@ class ErrorHandler implements PageErrorHandlerInterface
      * Status code of the response
      * @var int
      */
-    protected $statusCode;
+    protected int $statusCode;
 
     /**
      * Configuration of the error handler as set in site configuration.
      * @var array
      */
-    protected $errorHandlerConfiguration;
+    protected array $errorHandlerConfiguration;
 
     /**
      * @var ViewInterface

+ 15 - 29
ot_templating/Classes/Templating/TemplateRepository.php

@@ -2,9 +2,11 @@
 
 namespace Opentalent\OtTemplating\Templating;
 
-use Opentalent\OtCore\Page\OtPageRepository;
+use Opentalent\OtCore\Website\OtPageRepository;
+use Opentalent\OtCore\Website\OtWebsiteRepository;
 use TYPO3\CMS\Core\Database\ConnectionPool;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
+use TYPO3\CMS\Extbase\Object\ObjectManager;
 
 /**
  * Class TemplateRepository
@@ -14,16 +16,6 @@ use TYPO3\CMS\Core\Utility\GeneralUtility;
  */
 class TemplateRepository
 {
-    /**
-     * @var \TYPO3\CMS\Core\Database\ConnectionPool
-     */
-    private $connectionPool;
-
-    public function injectConnectionPool(\TYPO3\CMS\Core\Database\ConnectionPool $connectionPool)
-    {
-        $this->connectionPool = $connectionPool;
-    }
-
     CONST templates = [
         'Classic' => [
             'name' => 'Classique',
@@ -51,20 +43,17 @@ class TemplateRepository
      * @param int $rootUid
      * @return string
      */
-    public function getTemplate(int $rootUid) {
+    public function getTemplate(int $rootUid): string
+    {
         if (!($rootUid >= 0)) {
             return self::defaultTemplate;
         }
 
-        $queryBuilder = $this->connectionPool->getQueryBuilderForTable('pages');
-        $templateName = $queryBuilder
-            ->select('tx_opentalent_template')
-            ->from('pages')
-            ->where($queryBuilder->expr()->eq('uid', $rootUid))
-            ->execute()
-            ->fetchColumn(0);
+        $otWebsiteRepository = GeneralUtility::makeInstance(ObjectManager::class)->get(OtWebsiteRepository::class);
+        $website = $otWebsiteRepository->getWebsiteByPageUid($rootUid);
+        $templateName = $website['template'];
 
-        if ($templateName==='') {
+        if ($templateName==='' || $templateName==null) {
             return self::defaultTemplate;
         }
         return $templateName;
@@ -75,20 +64,17 @@ class TemplateRepository
      * @param int $rootUid
      * @return array
      */
-    public function getTemplatePreferences(int $rootUid) {
-        $queryBuilder = $this->connectionPool->getQueryBuilderForTable('pages');
-        $templatePreferences = $queryBuilder
-            ->select('tx_opentalent_template_preferences')
-            ->from('pages')
-            ->where($queryBuilder->expr()->eq('uid', $rootUid))
-            ->execute()
-            ->fetchColumn(0);
+    public function getTemplatePreferences(int $rootUid): array
+    {
+        $otWebsiteRepository = GeneralUtility::makeInstance(ObjectManager::class)->get(OtWebsiteRepository::class);
+        $website = $otWebsiteRepository->getWebsiteByPageUid($rootUid);
+        $templatePreferences = $website['template_preferences'] ?? '';
 
         if ($templatePreferences !== '') {
             $templatePreferences = json_decode($templatePreferences, true);
         } else {
             $templatePreferences = [];
         }
-        return array_merge(self::defaultPreferences, $templatePreferences);;
+        return array_merge(self::defaultPreferences, $templatePreferences);
     }
 }

+ 1 - 1
ot_templating/Classes/ViewHelpers/Events/GetByIdViewHelper.php

@@ -33,7 +33,7 @@ class GetByIdViewHelper extends OtAbstractViewHelper {
     /**
      * @var EventRepository
      */
-    protected $eventRepository;
+    protected EventRepository $eventRepository;
 
     /**
      * -- This method is expected by Fluid --

+ 1 - 1
ot_templating/Classes/ViewHelpers/EventsPage/GetIdViewHelper.php

@@ -3,7 +3,7 @@
 namespace Opentalent\OtTemplating\ViewHelpers\EventsPage;
 
 use Closure;
-use Opentalent\OtCore\Page\OtPageRepository;
+use Opentalent\OtCore\Website\OtPageRepository;
 use Opentalent\OtCore\ViewHelpers\OtAbstractViewHelper;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 use TYPO3\CMS\Extbase\Object\ObjectManager;

+ 1 - 1
ot_templating/Classes/ViewHelpers/GetPageUidViewHelper.php

@@ -4,7 +4,7 @@ namespace Opentalent\OtTemplating\ViewHelpers;
 
 
 use Closure;
-use Opentalent\OtCore\Page\OtPageRepository;
+use Opentalent\OtCore\Website\OtPageRepository;
 use Opentalent\OtCore\ViewHelpers\OtAbstractViewHelper;
 use Opentalent\OtTemplating\ViewHelpers\RootPage\GetIdViewHelper;
 use TYPO3\CMS\Core\Utility\GeneralUtility;

+ 1 - 2
ot_templating/Classes/ViewHelpers/Members/GetAllCaViewHelper.php

@@ -34,7 +34,7 @@ class GetAllCaViewHelper extends OtAbstractViewHelper {
      * @var MemberRepository
      *
      */
-    protected $memberRepository;
+    protected MemberRepository $memberRepository;
 
     /**
      * -- This method is expected by Fluid --
@@ -70,7 +70,6 @@ class GetAllCaViewHelper extends OtAbstractViewHelper {
      *
      * @return string
      * @throws \GuzzleHttp\Exception\GuzzleException
-     * @throws \Opentalent\OtTemplating\Exception\ApiRequestException
      */
     public function render()
     {

+ 2 - 3
ot_templating/Classes/ViewHelpers/Members/GetAllViewHelper.php

@@ -34,7 +34,7 @@ class GetAllViewHelper extends OtAbstractViewHelper {
      * @var MemberRepository
      *
      */
-    protected $memberRepository;
+    protected MemberRepository $memberRepository;
 
     /**
      * -- This method is expected by Fluid --
@@ -69,9 +69,8 @@ class GetAllViewHelper extends OtAbstractViewHelper {
      * Renders the content as html
      *
      * @return string
-     * @throws ApiRequestException
      */
-    public function render()
+    public function render(): string
     {
         // Get current settings
         $as = $this->arguments['as'];

+ 1 - 3
ot_templating/Classes/ViewHelpers/Members/GetPresidentViewHelper.php

@@ -33,7 +33,7 @@ class GetPresidentViewHelper extends OtAbstractViewHelper {
      * @var MemberRepository
      *
      */
-    protected $memberRepository;
+    protected MemberRepository $memberRepository;
 
     /**
      * -- This method is expected by Fluid --
@@ -60,8 +60,6 @@ class GetPresidentViewHelper extends OtAbstractViewHelper {
      * Renders the content as html
      *
      * @return string
-     * @throws \GuzzleHttp\Exception\GuzzleException
-     * @throws \Opentalent\OtTemplating\Exception\ApiRequestException
      */
     public function render()
     {

+ 1 - 1
ot_templating/Classes/ViewHelpers/NewsPage/GetIdViewHelper.php

@@ -3,7 +3,7 @@
 namespace Opentalent\OtTemplating\ViewHelpers\NewsPage;
 
 use Closure;
-use Opentalent\OtCore\Page\OtPageRepository;
+use Opentalent\OtCore\Website\OtPageRepository;
 use Opentalent\OtCore\ViewHelpers\OtAbstractViewHelper;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 use TYPO3\CMS\Extbase\Object\ObjectManager;

+ 2 - 2
ot_templating/Classes/ViewHelpers/RootPage/GetIdViewHelper.php

@@ -3,7 +3,7 @@
 namespace Opentalent\OtTemplating\ViewHelpers\RootPage;
 
 use Closure;
-use Opentalent\OtCore\Page\OtPageRepository;
+use Opentalent\OtCore\Website\OtPageRepository;
 use Opentalent\OtCore\ViewHelpers\OtAbstractViewHelper;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 use TYPO3\CMS\Extbase\Object\ObjectManager;
@@ -36,6 +36,6 @@ class GetIdViewHelper extends OtAbstractViewHelper
         RenderingContextInterface $renderingContext
     ) {
         $pageRepository = GeneralUtility::makeInstance(ObjectManager::class)->get(OtPageRepository::class);
-        return $pageRepository->getCurrentSiteRootPageId();
+        return $pageRepository->getCurrentSiteRootPageUid();
     }
 }

+ 1 - 1
ot_templating/Classes/ViewHelpers/RootPage/GetUriViewHelper.php

@@ -4,7 +4,7 @@ namespace Opentalent\OtTemplating\ViewHelpers\RootPage;
 
 use Closure;
 use Opentalent\OtCore\ViewHelpers\OtAbstractViewHelper;
-use Opentalent\OtCore\Page\OtPageRepository;
+use Opentalent\OtCore\Website\OtPageRepository;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 use TYPO3\CMS\Extbase\Object\ObjectManager;
 use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface;

+ 2 - 2
ot_templating/Classes/ViewHelpers/Template/CurrentViewHelper.php

@@ -4,7 +4,7 @@ namespace Opentalent\OtTemplating\ViewHelpers\Template;
 
 
 use Closure;
-use Opentalent\OtCore\Page\OtPageRepository;
+use Opentalent\OtCore\Website\OtPageRepository;
 use Opentalent\OtCore\ViewHelpers\OtAbstractViewHelper;
 use Opentalent\OtTemplating\Templating\TemplateRepository;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
@@ -37,7 +37,7 @@ class CurrentViewHelper extends OtAbstractViewHelper
         RenderingContextInterface $renderingContext
     ) {
         $pageRepository = GeneralUtility::makeInstance(ObjectManager::class)->get(OtPageRepository::class);
-        $rootUid = $pageRepository->getCurrentSiteRootPageId();
+        $rootUid = $pageRepository->getCurrentSiteRootPageUid();
 
         $templateRepository = GeneralUtility::makeInstance(ObjectManager::class)->get(TemplateRepository::class);
         return $templateRepository->getTemplate($rootUid);

+ 2 - 2
ot_templating/Classes/ViewHelpers/Template/GetPreferenceViewHelper.php

@@ -4,7 +4,7 @@ namespace Opentalent\OtTemplating\ViewHelpers\Template;
 
 
 use Closure;
-use Opentalent\OtCore\Page\OtPageRepository;
+use Opentalent\OtCore\Website\OtPageRepository;
 use Opentalent\OtCore\ViewHelpers\OtAbstractViewHelper;
 use Opentalent\OtTemplating\Templating\TemplateRepository;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
@@ -51,7 +51,7 @@ class GetPreferenceViewHelper extends OtAbstractViewHelper
         RenderingContextInterface $renderingContext
     ) {
         $pageRepository = GeneralUtility::makeInstance(ObjectManager::class)->get(OtPageRepository::class);
-        $rootUid = $pageRepository->getCurrentSiteRootPageId();
+        $rootUid = $pageRepository->getCurrentSiteRootPageUid();
 
         $templateRepository = GeneralUtility::makeInstance(ObjectManager::class)->get(TemplateRepository::class);
         $preferences = $templateRepository->getTemplatePreferences($rootUid);

+ 2 - 2
ot_templating/Classes/ViewHelpers/Template/GetPreferencesViewHelper.php

@@ -3,7 +3,7 @@
 namespace Opentalent\OtTemplating\ViewHelpers\Template;
 
 use Closure;
-use Opentalent\OtCore\Page\OtPageRepository;
+use Opentalent\OtCore\Website\OtPageRepository;
 use Opentalent\OtCore\ViewHelpers\OtAbstractViewHelper;
 use Opentalent\OtTemplating\Templating\TemplateRepository;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
@@ -36,7 +36,7 @@ class PreferencesViewHelper extends OtAbstractViewHelper
         RenderingContextInterface $renderingContext
     ) {
         $pageRepository = GeneralUtility::makeInstance(ObjectManager::class)->get(OtPageRepository::class);
-        $rootUid = $pageRepository->getCurrentSiteRootPageId();
+        $rootUid = $pageRepository->getCurrentSiteRootPageUid();
 
         $templateRepository = GeneralUtility::makeInstance(TemplateRepository::class);
         return $templateRepository->getTemplatePreferences($rootUid);

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

@@ -2,7 +2,8 @@
 
 namespace Opentalent\OtTemplating\XClass\Form\Configuration;
 
-use Opentalent\OtCore\Page\OtPageRepository;
+use Opentalent\OtCore\Website\OtPageRepository;
+use Opentalent\OtCore\Website\OtWebsiteRepository;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 use TYPO3\CMS\Extbase\Object\ObjectManager;
 
@@ -22,9 +23,12 @@ class ConfigurationManager extends \TYPO3\CMS\Form\Mvc\Configuration\Configurati
 
         $otPageRepository = GeneralUtility::makeInstance(ObjectManager::class)->get(OtPageRepository::class);
         foreach ($otPageRepository->getCurrentBeUserMountpoints() as $rootUid) {
-            $organizationId = $otPageRepository->getPage($rootUid)['tx_opentalent_structure_id'];
-            if ($organizationId) {
-                $settings['persistenceManager']['allowedFileMounts'][] = '1:/form_definitions/' . $organizationId . '/';
+
+            $otWebsiteRepository = GeneralUtility::makeInstance(ObjectManager::class)->get(OtWebsiteRepository::class);
+            $website = $otWebsiteRepository->getWebsiteByPageUid($rootUid);
+
+            if ($website['organization_id']) {
+                $settings['persistenceManager']['allowedFileMounts'][] = '1:/form_definitions/' . $website['organization_id'] . '/';
             }
         }
 

+ 3 - 3
ot_templating/ext_tables.sql

@@ -3,7 +3,7 @@
 #
 # Table structure for table 'pages'
 #
-CREATE TABLE pages (
-    tx_opentalent_template varchar(100) DEFAULT '',
-    tx_opentalent_template_preferences text DEFAULT ''
+CREATE TABLE ot_websites (
+    template varchar(100) DEFAULT '',
+    template_preferences text DEFAULT ''
 );