StatsSettingsRepository.php 1.1 KB

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