<?php

namespace Opentalent\OtStats\Settings;

use Opentalent\OtCore\Website\OtWebsiteRepository;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Extbase\Object\ObjectManager;

/**
 * Class StatsRepository
 *
 * Give access to the website's settings for the stats module
 *
 * @package Opentalent\OtTemplating\Page
 */
class StatsSettingsRepository
{
    /**
     * Returns the website registered matomo site's id
     * @param int $rootPageUid
     * @return int|null
     */
    public function getMatomoSiteId(int $rootPageUid): ?int
    {
        $otWebsiteRepository = GeneralUtility::makeInstance(ObjectManager::class)->get(OtWebsiteRepository::class);
        $website = $otWebsiteRepository->getWebsiteByPageUid($rootPageUid);
        return $website['matomo_site_id'];
    }
}
