findAll() as $candidate) { if ($candidate->startDateTime >= $startDate && $candidate->startDateTime <= $endDate ) { $matching[] = $candidate; } } return $matching; } /** * Returns a user's meeting recordings. * * @param User $user * * @return ArrayCollection|Collection|RecordingEntity[] */ public function userRecordings($user) { return $this->matching( Criteria::create()->where( Criteria::expr()->in( 'meeting', $this->getEntityManager()->getRepository(MeetingEntity::class)->userMeetings($user)->toArray() ) ) ); } /** * @param DateTime $start * @param DateTime $end * @param User $user * * @return ArrayCollection|RecordingEntity[] */ public function getPeriodUserRecordings($start, $end, $user) { return $this->userRecordings($user)->filter( function ($meeting) use ($start, $end) { return $meeting->startDateTime >= $start && $meeting->startDateTime <= $end; } ); } }