StatsSettingsRepository.php 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. <?php
  2. namespace Opentalent\OtStats\Settings;
  3. use TYPO3\CMS\Core\Database\ConnectionPool;
  4. use TYPO3\CMS\Core\Utility\GeneralUtility;
  5. use TYPO3\CMS\Frontend\Page\PageRepository;
  6. /**
  7. * Class StatsRepository
  8. *
  9. * Give access to the website's settings for the stats module
  10. *
  11. * @package Opentalent\OtTemplating\Page
  12. */
  13. class StatsSettingsRepository extends PageRepository
  14. {
  15. /**
  16. * Returns the website registered matomo site's id
  17. * @param int $rootPageUid
  18. * @return int|null
  19. */
  20. public function getMatomoSiteId(int $rootPageUid) {
  21. $rootPageUid = $this->getPage($rootPageUid);
  22. // Set up a connection to the typo3 DB
  23. $cnnPool = GeneralUtility::makeInstance(ConnectionPool::class);
  24. $queryBuilder = $cnnPool->getQueryBuilderForTable('pages');
  25. $matomoId = $queryBuilder
  26. ->select('tx_opentalent_matomo_id')
  27. ->from('pages')
  28. ->where($queryBuilder->expr()->eq('uid', $rootPageUid))
  29. ->execute()
  30. ->fetchColumn(0);
  31. return $matomoId;
  32. }
  33. }