wip: filter twig component pre-select options

This commit is contained in:
2025-04-29 23:40:27 -05:00
parent 8a1a89f17d
commit 3971cf3260
4 changed files with 49 additions and 36 deletions

View File

@@ -2,6 +2,9 @@
namespace App\Twig\Components;
use Aimeos\Map;
use App\User\Framework\Repository\PreferencesRepository;
use Symfony\Bundle\SecurityBundle\Security;
use Symfony\UX\LiveComponent\Attribute\AsLiveComponent;
use Symfony\UX\LiveComponent\DefaultActionTrait;
@@ -9,4 +12,21 @@ use Symfony\UX\LiveComponent\DefaultActionTrait;
final class Filter
{
use DefaultActionTrait;
public array $preferences = [];
public array $userPreferences = [];
public function __construct(
private readonly PreferencesRepository $preferencesRepository,
private readonly Security $security,
) {
$this->preferences = Map::from($this->preferencesRepository->findEnabled())
->rekey(fn($element) => $element->getId())
->map(fn($element) => $element->getPreferenceOptions()->toArray())
->toArray();
$this->userPreferences = Map::from($this->security->getUser()->getUserPreferenceValues())
->toArray();
// dd($this->userPreferences);
}
}