wip-feat: populates filter from api options

This commit is contained in:
2025-04-29 22:10:47 -05:00
parent c3eaf109e3
commit 8a1a89f17d
9 changed files with 191 additions and 6 deletions

View File

@@ -0,0 +1,23 @@
<?php
namespace App\User\Framework\Controller\Api;
use Aimeos\Map;
use App\User\Framework\Repository\PreferencesRepository;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Attribute\Route;
class PreferencesApiController extends AbstractController
{
#[Route('/api/preferences/media', name: 'api_preferences_media')]
public function getMediaPreferences(
PreferencesRepository $preferencesRepository,
): Response {
return $this->json(
Map::from($preferencesRepository->findEnabled())
->rekey(fn($element) => $element->getId())
->toArray()
);
}
}

View File

@@ -0,0 +1,20 @@
<?php
namespace App\User\Framework\Controller\Api;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Bundle\SecurityBundle\Security;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Attribute\Route;
class UserApiController extends AbstractController
{
#[Route('/api/user/preferences/values', name: 'api_user_preferences_values')]
public function getUserPreferenceValues(
Security $security
): Response {
return $this->json(
$security->getUser()->getUserPreferenceValues()
);
}
}