| 123456789101112131415161718192021222324252627282930313233343536373839 |
- <?php
- namespace Opentalent\OtStats\Settings;
- use TYPO3\CMS\Core\Database\ConnectionPool;
- use TYPO3\CMS\Core\Utility\GeneralUtility;
- use TYPO3\CMS\Frontend\Page\PageRepository;
- /**
- * Class StatsRepository
- *
- * Give access to the website's settings for the stats module
- *
- * @package Opentalent\OtTemplating\Page
- */
- class StatsSettingsRepository extends PageRepository
- {
- /**
- * Returns the website registered matomo site's id
- * @param int $rootPageUid
- * @return int|null
- */
- public function getMatomoSiteId(int $rootPageUid) {
- // Set up a connection to the typo3 DB
- $cnnPool = GeneralUtility::makeInstance(ConnectionPool::class);
- $queryBuilder = $cnnPool->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;
- }
- }
|