Implermented front page and set public

This commit is contained in:
Michel 2024-11-04 16:31:21 +01:00
parent 15a9dcf09b
commit d6ebf8f4ff
18 changed files with 658 additions and 23 deletions

41
src/php/UserManager.php Normal file
View file

@ -0,0 +1,41 @@
<?php
namespace GamesShop;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\EntityManager;
use GamesShop\Entities\Account\User;
use GamesShop\Entities\GamesList;
class UserManager
{
public function __construct(
private readonly EntityManager $entityManager
)
{
}
public function getApplicableGameLists(User $user): Collection {
$listRepo = $this->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;
}
}