program - show events without sessions at the end of next events #18
This commit is contained in:
parent
9c55ee0e5d
commit
881f384e22
2 changed files with 21 additions and 17 deletions
|
|
@ -1,36 +1,37 @@
|
|||
<?php
|
||||
|
||||
return function($kirby) {
|
||||
$orderedSeason = new Pages();
|
||||
|
||||
foreach ($kirby->collection('current-season')->children() as $event) {
|
||||
$sessions = $event->isMapadoEvent() == 'true' ? $event->remoteSessions()->toStructure() : $event->sessions()->toStructure();
|
||||
|
||||
$sessionDates = $sessions->map(function($session) {
|
||||
return $session->date()->value();
|
||||
})->data;
|
||||
|
||||
if (!empty($sessionDates)) {
|
||||
$orderedSeason->add($event);
|
||||
}
|
||||
$orderedSeason->add($event);
|
||||
}
|
||||
|
||||
$endOfProgramEvents = $orderedSeason->filter(function ($event) {
|
||||
$sessions = $event->isMapadoEvent() == 'true' ? $event->remoteSessions()->toStructure() : $event->sessions()->toStructure();
|
||||
$sessionDates = $sessions->map(function($session) {
|
||||
return $session->date()->value();
|
||||
})->data;
|
||||
|
||||
$normalEvents = $orderedSeason->filter(function ($event) {
|
||||
return $event->status() === 'listed';
|
||||
return empty($sessionDates) || $event->status() === 'unlisted';
|
||||
});
|
||||
|
||||
$endOfProgramEvents = $orderedSeason->filter(function ($event) {
|
||||
return $event->status() === 'unlisted';
|
||||
$normalEvents = $orderedSeason->filter(function ($event) use ($endOfProgramEvents) {
|
||||
return $event->status() === 'listed' && !$endOfProgramEvents->has($event);
|
||||
});
|
||||
|
||||
$normalEvents = $normalEvents->sortBy(function ($event) {
|
||||
$sessions = $event->isMapadoEvent() == 'true' ? $event->remoteSessions()->toStructure() : $event->sessions()->toStructure();
|
||||
|
||||
$sessionDates = $sessions->map(function($session) {
|
||||
return $session->date()->value();
|
||||
})->data;
|
||||
|
||||
return min($sessionDates);
|
||||
return !empty($sessionDates) ? min($sessionDates) : PHP_INT_MAX;
|
||||
});
|
||||
|
||||
$orderedSeason = $normalEvents->merge($endOfProgramEvents);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue