currentWebsite['matomo_site_id']; if ($matomoId == null) { return new ForwardResponse('askForActivationConfirmation'); } $this->view->assign('matomoSiteId', (int)$matomoId); $this->view->assign('matomoToken', self::MATOMO_TOKEN); $args = $this->request->getArguments(); // Default interval $period = $args['period'] ?? 'month'; $this->view->assign('period', $period); return $this->htmlResponse(); } /** * Display a confirmation page before enabling the stats module */ public function askForActivationConfirmationAction(): ResponseInterface { return $this->htmlResponse(); } /** * Display a confirmation page before disabling the stats module */ public function askForDeactivationConfirmationAction(): ResponseInterface { $this->view->assign('rootUid', $this->currentRootUid); return $this->htmlResponse(); } /** * Creates a matomo site record if none exists and * save its id */ public function enableStatsAction(): ResponseInterface { try { $this->matomoWebsiteRepository->createFor($this->currentRootUid); } catch (\RuntimeException $e) { OtLogger::error("OtStats - " . $e); $this->addFlashMessage( $this->getLanguageService()->sL( 'LLL:EXT:ot_core/Resources/Private/Language/locallang.xlf:an_error_occured' ), '', AbstractMessage::ERROR ); return new ForwardResponse('askForActivationConfirmation'); } return new ForwardResponse('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): ResponseInterface { try { $this->matomoWebsiteRepository->disableFor($rootUid); } catch (\RuntimeException $e) { OtLogger::error("OtStats - " . $e); $this->addFlashMessage( $this->getLanguageService()->sL( 'LLL:EXT:ot_core/Resources/Private/Language/locallang.xlf:an_error_occured' ), '', AbstractMessage::ERROR ); } return new ForwardResponse('askForActivationConfirmation'); } }