wip: filter twig component pre-select options
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user