entityManager->getRepository(GamesList::class); $allLists = $listRepo->findAll(); $applicableLists = new ArrayCollection(); foreach ($allLists as $list) { if ($list->isPublic()) { $applicableLists->add($list); continue; } if (!$list->getClaimer()->contains($user)) { continue; } $applicableLists->add($list); } return $applicableLists; } }