Loading config/packages/fos_elastica.yaml +37 −1 Original line number Diff line number Diff line Loading @@ -20,6 +20,42 @@ fos_elastica: type: text parent_id: type: integer product_attributes: type: object properties: id: type: integer product: type: object properties: id: type: integer name: type: text price: type: float attribute: type: object properties: id: type: integer name: type: text type: type: text value_item: type: object properties: id: type: integer name: type: text value_int: type: integer value_date: type: date value_bool: type: boolean persistence: driver: orm model: App\Entity\Product Loading Loading @@ -85,7 +121,7 @@ fos_elastica: type: text type: type: text attribute_item: value_item: type: object properties: id: Loading config/services.yaml +4 −1 Original line number Diff line number Diff line Loading @@ -22,3 +22,6 @@ services: # add more service definitions when explicit configuration is needed # please note that last definitions always *replace* previous ones App\Service\FilterService: $finder: '@fos_elastica.finder.product' No newline at end of file src/Attribute/RequestQuery.php 0 → 100644 +10 −0 Original line number Diff line number Diff line <?php declare(strict_types=1); namespace App\Attribute; #[\Attribute(\Attribute::TARGET_PARAMETER)] class RequestQuery { } src/Controller/FilterController.php 0 → 100644 +34 −0 Original line number Diff line number Diff line <?php declare(strict_types=1); namespace App\Controller; use App\Attribute\RequestQuery; use App\Request\GetFilteredProductsRequest; use App\Service\FilterService; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\Routing\Attribute\Route; class FilterController extends AbstractController { public function __construct(private FilterService $filterService) { } #[Route('/products/filters', methods: ['GET'])] public function getFilters(): Response { return $this->json($this->filterService->getFilters()); } #[Route('/products/filters', methods: ['POST'])] public function getProducts(#[RequestQuery] GetFilteredProductsRequest $request): Response { return $this->json($this->filterService->getProducts($request), context: [ 'circular_reference_handler' => function ($object) { return $object->getId(); }, 'groups' => ['product_attribute', 'product', 'category', 'attribute_item', 'attribute'] ]); } } src/Entity/Attribute.php +2 −0 Original line number Diff line number Diff line Loading @@ -6,8 +6,10 @@ namespace App\Entity; use App\Repository\AttributeRepository; use Doctrine\ORM\Mapping as ORM; use Symfony\Component\Serializer\Attribute\Groups; #[ORM\Entity(repositoryClass: AttributeRepository::class)] #[Groups('attribute')] class Attribute { #[ORM\Id] Loading Loading
config/packages/fos_elastica.yaml +37 −1 Original line number Diff line number Diff line Loading @@ -20,6 +20,42 @@ fos_elastica: type: text parent_id: type: integer product_attributes: type: object properties: id: type: integer product: type: object properties: id: type: integer name: type: text price: type: float attribute: type: object properties: id: type: integer name: type: text type: type: text value_item: type: object properties: id: type: integer name: type: text value_int: type: integer value_date: type: date value_bool: type: boolean persistence: driver: orm model: App\Entity\Product Loading Loading @@ -85,7 +121,7 @@ fos_elastica: type: text type: type: text attribute_item: value_item: type: object properties: id: Loading
config/services.yaml +4 −1 Original line number Diff line number Diff line Loading @@ -22,3 +22,6 @@ services: # add more service definitions when explicit configuration is needed # please note that last definitions always *replace* previous ones App\Service\FilterService: $finder: '@fos_elastica.finder.product' No newline at end of file
src/Attribute/RequestQuery.php 0 → 100644 +10 −0 Original line number Diff line number Diff line <?php declare(strict_types=1); namespace App\Attribute; #[\Attribute(\Attribute::TARGET_PARAMETER)] class RequestQuery { }
src/Controller/FilterController.php 0 → 100644 +34 −0 Original line number Diff line number Diff line <?php declare(strict_types=1); namespace App\Controller; use App\Attribute\RequestQuery; use App\Request\GetFilteredProductsRequest; use App\Service\FilterService; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\Routing\Attribute\Route; class FilterController extends AbstractController { public function __construct(private FilterService $filterService) { } #[Route('/products/filters', methods: ['GET'])] public function getFilters(): Response { return $this->json($this->filterService->getFilters()); } #[Route('/products/filters', methods: ['POST'])] public function getProducts(#[RequestQuery] GetFilteredProductsRequest $request): Response { return $this->json($this->filterService->getProducts($request), context: [ 'circular_reference_handler' => function ($object) { return $object->getId(); }, 'groups' => ['product_attribute', 'product', 'category', 'attribute_item', 'attribute'] ]); } }
src/Entity/Attribute.php +2 −0 Original line number Diff line number Diff line Loading @@ -6,8 +6,10 @@ namespace App\Entity; use App\Repository\AttributeRepository; use Doctrine\ORM\Mapping as ORM; use Symfony\Component\Serializer\Attribute\Groups; #[ORM\Entity(repositoryClass: AttributeRepository::class)] #[Groups('attribute')] class Attribute { #[ORM\Id] Loading