From b77c301d8c9cfb3d3ad464455e57b5b8b1b6015a Mon Sep 17 00:00:00 2001 From: Oliver Davies Date: Fri, 28 Aug 2020 18:01:47 +0100 Subject: [PATCH] Refactor to use a short function --- web/modules/custom/opdavies_talks/src/Service/TalkCounter.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/web/modules/custom/opdavies_talks/src/Service/TalkCounter.php b/web/modules/custom/opdavies_talks/src/Service/TalkCounter.php index de522c810..2159bdfba 100644 --- a/web/modules/custom/opdavies_talks/src/Service/TalkCounter.php +++ b/web/modules/custom/opdavies_talks/src/Service/TalkCounter.php @@ -8,6 +8,7 @@ use Carbon\Carbon; use Drupal\Core\Entity\EntityStorageInterface; use Drupal\Core\Entity\EntityTypeManagerInterface; use Drupal\node\NodeInterface; +use Drupal\opdavies_talks\Entity\Node\Talk; use Drupal\paragraphs\ParagraphInterface; use Illuminate\Support\Collection; @@ -23,7 +24,7 @@ final class TalkCounter { $today = Carbon::today()->format('Y-m-d H:i:s'); return $this->getTalks() - ->flatMap->getEvents() + ->flatMap(fn(Talk $talk) => $talk->getEvents()) ->filter(fn(ParagraphInterface $event) => $event->get('field_date')->getString() <= $today) ->count(); }