api api
All checks were successful
/ ls (release) Successful in 55s
/ ls (pull_request) Successful in 1m28s
/ ls (push) Successful in 1m26s

This commit is contained in:
lubiana 2025-06-15 13:57:17 +02:00
parent 9d2f0204e3
commit ee32852789
Signed by: lubiana
SSH key fingerprint: SHA256:vW1EA0fRR3Fw+dD/sM0K+x3Il2gSry6YRYHqOeQwrfk
12 changed files with 514 additions and 3 deletions

0
src/ApiResource/.gitignore vendored Normal file
View file

View file

@ -2,7 +2,14 @@
namespace App\Entity;
use ApiPlatform\Metadata\ApiResource;
use ApiPlatform\Metadata\Delete;
use ApiPlatform\Metadata\Get;
use ApiPlatform\Metadata\GetCollection;
use ApiPlatform\Metadata\Post;
use ApiPlatform\Metadata\Put;
use App\Repository\FoodOrderRepository;
use App\State\OpenOrdersProvider;
use DateInterval;
use DateTimeImmutable;
use Doctrine\Common\Collections\ArrayCollection;
@ -13,6 +20,20 @@ use Symfony\Component\Uid\Ulid;
use function iterator_to_array;
#[ApiResource(
operations: [
new GetCollection(
uriTemplate: 'food_orders/open',
description: 'Get only open orders',
provider: OpenOrdersProvider::class,
),
new GetCollection,
new Get,
new Post,
new Put,
new Delete,
]
)]
#[ORM\Entity(repositoryClass: FoodOrderRepository::class)]
class FoodOrder
{

View file

@ -2,6 +2,7 @@
namespace App\Entity;
use ApiPlatform\Metadata\ApiResource;
use App\Repository\FoodVendorRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
@ -11,6 +12,7 @@ use Symfony\Bridge\Doctrine\Types\UlidType;
use Symfony\Component\Uid\Ulid;
#[ORM\Entity(repositoryClass: FoodVendorRepository::class)]
#[ApiResource]
class FoodVendor
{
#[ORM\Column(length: 50)]

View file

@ -2,6 +2,7 @@
namespace App\Entity;
use ApiPlatform\Metadata\ApiResource;
use App\Repository\MenuItemRepository;
use DateTimeImmutable;
use Doctrine\Common\Collections\ArrayCollection;
@ -11,6 +12,7 @@ use Symfony\Bridge\Doctrine\IdGenerator\UlidGenerator;
use Symfony\Bridge\Doctrine\Types\UlidType;
use Symfony\Component\Uid\Ulid;
#[ApiResource]
#[ORM\Entity(repositoryClass: MenuItemRepository::class)]
class MenuItem
{

View file

@ -2,12 +2,14 @@
namespace App\Entity;
use ApiPlatform\Metadata\ApiResource;
use App\Repository\OrderItemRepository;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Bridge\Doctrine\IdGenerator\UlidGenerator;
use Symfony\Bridge\Doctrine\Types\UlidType;
use Symfony\Component\Uid\Ulid;
#[ApiResource]
#[ORM\Entity(repositoryClass: OrderItemRepository::class)]
class OrderItem
{

View file

@ -0,0 +1,25 @@
<?php declare(strict_types=1);
namespace App\State;
use ApiPlatform\Metadata\Operation;
use ApiPlatform\State\ProviderInterface;
use App\Entity\FoodOrder;
use App\Repository\FoodOrderRepository;
use Override;
final readonly class OpenOrdersProvider implements ProviderInterface
{
public function __construct(
private FoodOrderRepository $repository
) {}
/**
* @return FoodOrder[]
*/
#[Override]
public function provide(Operation $operation, array $uriVariables = [], array $context = []): array
{
return $this->repository->findOpenOrders();
}
}