view->assign('rootPage', $this->currentRootUid); $statsSettingsRepository = GeneralUtility::makeInstance(StatsSettingsRepository::class); $matomoId = $statsSettingsRepository->getMatomoSiteId($this->currentRootUid); if ($matomoId == null) { $this->forward('askForActivationConfirmation'); } $this->view->assign('matomoSiteId', (int)$matomoId); } /** * Display a confirmation page before enabling the stats module */ public function askForActivationConfirmationAction() {} /** * Display a confirmation page before disabling the stats module */ public function askForDeactivationConfirmationAction() { $this->view->assign('rootUid', $this->currentRootUid); } /** * Creates a matomo site record if none exists and * save its id */ public function enableStatsAction() { $matomoRepository = GeneralUtility::makeInstance(MatomoWebsiteRepository::class); try { $matomoRepository->createFor($this->currentRootUid); } catch (\RuntimeException $e) { OtLogger::error("OtStats - " . $e); $this->addFlashMessage( "Une erreur s'est produite lors de l'opération, veuillez contacter un administrateur.", '', AbstractMessage::ERROR ); $this->forward('askForActivationConfirmation'); } $this->forward('index'); } /** * Disable the stats monitoring * * @param int $rootUid Pass the rootUid of the site as an argument to confirm of the decision * of disabling the website. If no rootUid is passed, the user will be redirected to a * confirmation page. * @throws StopActionException */ public function disableStatsAction(int $rootUid) { $matomoRepository = GeneralUtility::makeInstance(MatomoWebsiteRepository::class); try { $matomoRepository->disableFor($rootUid); } catch (\RuntimeException $e) { OtLogger::error("OtStats - " . $e); $this->addFlashMessage( "Une erreur s'est produite lors de l'opération, veuillez contacter un administrateur.", '', AbstractMessage::ERROR ); } $this->forward('askForActivationConfirmation'); } }