feature/RVRNEXT-11-events #54

Merged
bence merged 13 commits from feature/RVRNEXT-11-events into master 2023-05-28 16:52:49 +02:00
2 changed files with 13 additions and 2 deletions
Showing only changes of commit f370ccba88 - Show all commits

View File

@ -1,8 +1,10 @@
<?php namespace RVR\Controller; <?php namespace RVR\Controller;
use DateTime;
use RVR\PersistentData\Model\Community; use RVR\PersistentData\Model\Community;
use RVR\PersistentData\Model\User; use RVR\PersistentData\Model\User;
use RVR\Repository\CommunityMemberRepository; use RVR\Repository\CommunityMemberRepository;
use RVR\Repository\EventRepository;
use SokoWeb\Interfaces\Authentication\IAuthenticationRequired; use SokoWeb\Interfaces\Authentication\IAuthenticationRequired;
use SokoWeb\Interfaces\Response\IContent; use SokoWeb\Interfaces\Response\IContent;
use SokoWeb\Response\HtmlContent; use SokoWeb\Response\HtmlContent;
@ -11,9 +13,12 @@ class HomeController implements IAuthenticationRequired
{ {
private CommunityMemberRepository $communityMemberRepository; private CommunityMemberRepository $communityMemberRepository;
private EventRepository $eventRepository;
public function __construct() public function __construct()
{ {
$this->communityMemberRepository = new CommunityMemberRepository(); $this->communityMemberRepository = new CommunityMemberRepository();
$this->eventRepository = new EventRepository();
} }
public function isAuthenticationRequired(): bool public function isAuthenticationRequired(): bool
@ -39,7 +44,7 @@ class HomeController implements IAuthenticationRequired
return new HtmlContent('home', [ return new HtmlContent('home', [
'communities' => $communities, 'communities' => $communities,
'upcomingEvents' => [] 'upcomingEvents' => iterator_to_array($this->eventRepository->getUpcomingByUser($user, new DateTime(), 3, true, ['community']))
]); ]);
} }
} }

View File

@ -19,7 +19,13 @@
<h3 class="marginBottom">Upcoming events</h3> <h3 class="marginBottom">Upcoming events</h3>
<?php if (count($upcomingEvents) > 0): ?> <?php if (count($upcomingEvents) > 0): ?>
<?php foreach ($upcomingEvents as $event): ?> <?php foreach ($upcomingEvents as $event): ?>
<!-- todo --> <p>
<a href="<?= Container::$routeCollection->getRoute('community.event')->generateLink(['communitySlug' => $event->getCommunity()->getSlug(), 'eventSlug' => $event->getSlug()]) ?>"><?= $event->getTitle() ?></a>
<span class="small">
(<a href="<?= Container::$routeCollection->getRoute('community')->generateLink(['communitySlug' => $event->getCommunity()->getSlug()]) ?>"><?= $event->getCommunity()->getName() ?></a>)
<?= $event->getStartDate()->format('Y-m-d') ?> <?= $event->getEndDate()->format('Y-m-d') ?>
</span>
</p>
<?php endforeach; ?> <?php endforeach; ?>
<?php else: ?> <?php else: ?>
<p>There is no upcoming event.</p> <p>There is no upcoming event.</p>