Add function for getting events for a talk
GH-160
This commit is contained in:
parent
105ae345a9
commit
5499f555c1
4 changed files with 86 additions and 5 deletions
|
|
@ -33,6 +33,7 @@ class TalksExtension extends AbstractExtension
|
|||
new TwigFunction('get_upcoming_talks', [$this, 'getUpcomingTalks']),
|
||||
new TwigFunction('get_past_talks', [$this, 'getPastTalks']),
|
||||
new TwigFunction('get_past_talk_count', [$this, 'getPastTalkCount']),
|
||||
new TwigFunction('get_events_for_talk', [$this, 'getEventsForTalk']),
|
||||
];
|
||||
}
|
||||
|
||||
|
|
@ -89,6 +90,18 @@ class TalksExtension extends AbstractExtension
|
|||
return $this->getPastEvents($talks)->count();
|
||||
}
|
||||
|
||||
public function getEventsForTalk(array $talk, array $eventData): Collection
|
||||
{
|
||||
return (new Collection($talk['events']))
|
||||
->map(function (array $event) use ($eventData): Collection {
|
||||
return (new Collection($event))->merge($eventData[$event['event']]);
|
||||
})
|
||||
->filter(function (Collection $event): bool {
|
||||
return !empty($event->get('date'));
|
||||
})
|
||||
->sortBy('date');
|
||||
}
|
||||
|
||||
private function getLastDate($talk): string
|
||||
{
|
||||
return $this->eventsFromTalks(new Collection([$talk]))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue