isMapadoEvent() == 'true'; $arraySession = $session->toArray(); $arraySession['title'] = $event->title()->value(); $arraySession['authors'] = $event->authors()->inline(); $arraySession['place'] = $event->place(); $arraySession['public'] = $event->public(); $arraySession['event-url'] = $event->url(); $arraySession['duration'] = $event->duration(); $arraySession['ticketingUrl'] = $isMapadoEvent ? $session->ticketingUrl() : false; $arraySession['bookableStock'] = $isMapadoEvent ? $session->bookableStock()->value() : 'free'; $arraySession['totalStock'] = $isMapadoEvent ? (int) $event->totalStock()->value() : 'free'; $arraySession['color'] = $event->color(); $arraySession['categories'] = $event->categories(); return $arraySession; } return function($kirby, $page) { $currentSeason = $page->children()->first(); $today = date('Ymd'); $currentSeasonSessions = []; foreach ($currentSeason->children() as $event) { $sessions = $event->isMapadoEvent() == 'true' ? $event->remoteSessions() : $event->sessions(); $isStillShowing = false; foreach ($sessions->toStructure() as $session) { $arraySession = createArraySession($event, $session); $currentSeasonSessions[] = $arraySession; $sessionDate = str_replace('-', '', $session->date()->toDate('YMMdd')); if ($sessionDate >= $today) { $isStillShowing = true; } } } return [ 'pastEvents' => filterPastEvents($kirby->collection('ordered-season')), 'futureEvents' => filterFutureEvents($kirby->collection('ordered-season')), 'currentSeasonSessions' => sortByMonth($currentSeasonSessions) ]; };