| 123456789101112131415161718192021222324252627282930313233343536373839404142434445 |
- <?php
- namespace Opentalent\OtStats\Settings;
- /**
- * Class StatsRepository
- *
- * Give access to the website's settings for the stats module
- *
- * @package Opentalent\OtTemplating\Page
- */
- 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)
- {
- // 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;
- }
- }
|