nodeStorage = $entityTypeManager->getStorage('node'); } public function getCount(): int { $today = Carbon::today()->format('Y-m-d H:i:s'); return $this->getTalks() ->flatMap->getEvents() ->filter(fn(ParagraphInterface $event) => $event->get('field_date')->getString() <= $today) ->count(); } private function getTalks(): Collection { $talks = $this->nodeStorage->loadByProperties([ 'status' => NodeInterface::PUBLISHED, 'type' => 'talk', ]); return new Collection($talks); } }