<?php
declare(strict_types=1);
namespace App\Domain\Entity;
use ApiPlatform\Metadata\ApiProperty;
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 Gedmo\SoftDeleteable\Traits\SoftDeleteable;
#[ApiResource(
operations : [
new Delete(security: "is_granted('ROLE_ADMIN')"),
new GetCollection(
paginationEnabled: false,
),
new Get(),
new Post(security: "is_granted('ROLE_ADMIN')"),
new Put(security: "is_granted('ROLE_ADMIN')"),
],
normalizationContext : ['groups' => ['region_read']],
denormalizationContext: ['groups' => ['region_write']],
order : ["countryCode" => "DESC"]
)]
class Region
{
use SoftDeleteable;
#[ApiProperty(identifier: true)]
public ?int $id = null;
public function __construct(
public string $name,
public string $iso31665,
public string $countryName,
public int $countryCode,
public ?string $remoteId = null
) {
}
}