RVRNEXT-11 add upcoming events for user

This commit is contained in:
Bence Pőcze 2023-05-28 04:05:53 +02:00
parent 3ff3a49d12
commit 6f1f59990f
Signed by: bence
GPG Key ID: DC5BD6E95A333E6D
2 changed files with 13 additions and 2 deletions

View File

@ -1,8 +1,10 @@
<?php namespace RVR\Controller;
use DateTime;
use RVR\PersistentData\Model\Community;
use RVR\PersistentData\Model\User;
use RVR\Repository\CommunityMemberRepository;
use RVR\Repository\EventRepository;
use SokoWeb\Interfaces\Authentication\IAuthenticationRequired;
use SokoWeb\Interfaces\Response\IContent;
use SokoWeb\Response\HtmlContent;
@ -11,9 +13,12 @@ class HomeController implements IAuthenticationRequired
{
private CommunityMemberRepository $communityMemberRepository;
private EventRepository $eventRepository;
public function __construct()
{
$this->communityMemberRepository = new CommunityMemberRepository();
$this->eventRepository = new EventRepository();
}
public function isAuthenticationRequired(): bool
@ -39,7 +44,7 @@ class HomeController implements IAuthenticationRequired
return new HtmlContent('home', [
'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>
<?php if (count($upcomingEvents) > 0): ?>
<?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 else: ?>
<p>There is no upcoming event.</p>