<?php
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\Controller\Action\CategoryTreeAction;
use App\Controller\Action\ExportByIdentifierAction;
use App\Repository\ExportRepository;
use App\State\CompliancePostProcessor;
use App\State\ExportPostProcessor;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Serializer\Annotation\Groups;
use App\Controller\Action\DownloadExportByIdentifier;
#[ORM\Entity(repositoryClass: ExportRepository::class)]
#[ApiResource(
normalizationContext: ['groups' => ['export.get']],
denormalizationContext: ['groups' => ['export.write']],
operations: [
new GetCollection(),
new Post(
processor: ExportPostProcessor::class
),
new Get(),
new Get(
uriTemplate: '/exports/by-identifier/{identifier}',
requirements: ['identifier' => '.+'],
controller: ExportByIdentifierAction::class,
read: false,
deserialize: false
),
new Put(),
new Get(
uriTemplate: '/exports/{identifier}/download',
controller: DownloadExportByIdentifier::class,
requirements: ['identifier' => '.+'],
read: false,
deserialize: false
),
new Delete(),
]
)]
class Export
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
private ?int $id = null;
#[ORM\Column(length: 255)]
#[Groups(['export.get', 'export.write'])]
private ?string $model = null;
#[ORM\Column(length: 255)]
#[Groups(['export.get', 'export.write'])]
private ?string $status = null;
#[ORM\Column]
#[Groups(['export.get', 'export.write'])]
private ?\DateTimeImmutable $createdAt = null;
#[ORM\Column]
#[Groups(['export.get', 'export.write'])]
private ?\DateTimeImmutable $updatedAt = null;
#[ORM\Column(type: Types::TEXT, nullable: true)]
#[Groups(['export.get', 'export.write'])]
private ?string $message = null;
#[ORM\ManyToOne(inversedBy: 'exports')]
#[ORM\JoinColumn(nullable: false)]
#[Groups(['export.get', 'export.write'])]
private ?User $user = null;
#[ORM\Column(length: 255, nullable: true)]
#[Groups(['export.get', 'export.write'])]
private ?string $file = null;
#[ORM\Column(nullable: true)]
#[Groups(['export.get', 'export.write'])]
private array $params = [];
#[ORM\Column(nullable: true)]
#[Groups(['export.get'])]
private ?string $identifier = null;
#[ORM\Column(length: 255, nullable: true)]
#[Groups(['export.get', 'export.write'])]
private ?int $siteId = null;
public function getId(): ?int
{
return $this->id;
}
public function getModel(): ?string
{
return $this->model;
}
public function setModel(string $model): self
{
$this->model = $model;
return $this;
}
public function getStatus(): ?string
{
return $this->status;
}
public function setStatus(string $status): self
{
$this->status = $status;
return $this;
}
public function getCreatedAt(): ?\DateTimeImmutable
{
return $this->createdAt;
}
public function setCreatedAt(\DateTimeImmutable $createdAt): self
{
$this->createdAt = $createdAt;
return $this;
}
public function getUpdatedAt(): ?\DateTimeImmutable
{
return $this->updatedAt;
}
public function setUpdatedAt(\DateTimeImmutable $updatedAt): self
{
$this->updatedAt = $updatedAt;
return $this;
}
public function getMessage(): ?string
{
return $this->message;
}
public function setMessage(?string $message): self
{
$this->message = $message;
return $this;
}
public function getUser(): ?User
{
return $this->user;
}
public function setUser(?User $user): self
{
$this->user = $user;
return $this;
}
public function getFile(): ?string
{
return $this->file;
}
public function setFile(?string $file): self
{
$this->file = $file;
return $this;
}
public function getParams(): array
{
return $this->params;
}
public function setParams(?array $params): self
{
$this->params = $params;
return $this;
}
/**
* @return string|null
*/
public function getIdentifier(): ?string
{
return $this->identifier;
}
/**
* @param string|null $identifier
*/
public function setIdentifier(?string $identifier): void
{
$this->identifier = $identifier;
}
/**
* @return int|null
*/
public function getSiteId(): ?int
{
return $this->siteId;
}
/**
* @param int|null $siteId
*/
public function setSiteId(?int $siteId): void
{
$this->siteId = $siteId;
}
}