<?php
namespace App\Domain\Entity;
use ApiPlatform\Metadata\ApiResource;
use ApiPlatform\Metadata\Delete;
use ApiPlatform\Metadata\Get;
use ApiPlatform\Metadata\GetCollection;
use App\Application\Controller\Api\TripExport\DeleteAction;
use App\Application\Controller\Api\TripExport\DownloadAction;
use App\Domain\Entity\Behavior\Identifiable;
use Gedmo\Timestampable\Traits\Timestampable;
#[ApiResource(
operations : [
new GetCollection(security: "is_granted('ROLE_ADMIN')"),
new Get(uriTemplate: 'trip_exports/{uuid}', security: "is_granted('ROLE_ADMIN')"),
new Get(
uriTemplate: 'trip_exports/{uuid}/download',
controller : DownloadAction::class,
security : "is_granted('ROLE_ADMIN')"
),
new Delete(controller: DeleteAction::class, security: "is_granted('ROLE_ADMIN')"),
],
normalizationContext: ['groups' => ['trip_export_read']],
)]
class TripExport
{
use Timestampable;
use Identifiable;
public const STATUS_PENDING = "pending";
public const STATUS_SUCCESS = "success";
public const STATUS_ERROR = "error";
public function __construct(
public ?string $path = null,
public string $status = self::STATUS_PENDING,
public ?string $error = null,
) {}
}