eventRepository = new EventRepository(); } public function isAuthenticationRequired(): bool { return true; } public function getEvent() { $currentEvent = $this->getCurrentEvent(); if ($currentEvent === null) { return new HtmlContent('event_redirect/no_event'); } return new Redirect( \Container::$routeCollection->getRoute('community.event') ->generateLink([ 'communitySlug' => $currentEvent->getCommunity()->getSlug(), 'eventSlug' => $currentEvent->getSlug() ]), IRedirect::TEMPORARY ); } public function getEventNewTransaction() { $currentEvent = $this->getCurrentEvent(); if ($currentEvent === null) { return new HtmlContent('event_redirect/no_event'); } return new Redirect( \Container::$routeCollection->getRoute('community.transactions.new') ->generateLink([ 'communitySlug' => $currentEvent->getCommunity()->getSlug(), 'event' => $currentEvent->getSlug() ]), IRedirect::TEMPORARY ); } private function getCurrentEvent(): ?Event { /** * @var User $user */ $user = Container::$request->user(); return $this->eventRepository->getCurrentByUser($user, new DateTime(), 30, true, ['community']); } }