<?php
namespace App\Entity;
use ApiPlatform\Doctrine\Orm\Filter\SearchFilter;
use ApiPlatform\Metadata\ApiFilter;
use ApiPlatform\Metadata\ApiResource;
use ApiPlatform\Metadata\Get;
use ApiPlatform\Metadata\GetCollection;
use ApiPlatform\Metadata\Post;
use App\Controller\Action\ImportActionController;
use App\Controller\Action\UploadDataTmpFileAction;
use App\Repository\ImportRepository;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity(repositoryClass: ImportRepository::class)]
#[ApiResource(
operations: [
new Get(),
new GetCollection(),
new Post(
uriTemplate: '/imports/import',
controller: ImportActionController::class,
openapiContext: [
'requestBody' => [
'content' => [
'multipart/form-data' => [
'schema' => [
'type' => 'object',
'properties' => [
'model' => [
'type' => 'string',
'format' => 'int'
],
'params' => [
'type' => 'array',
'format' => 'array'
],
'file' => [
'type' => 'string',
'format' => 'binary'
],
'site_id' => [
'type' => 'string',
'format' => 'int'
]
]
]
]
]
]
],
deserialize: false,
validate: false
)
]
)]
#[ApiFilter(
SearchFilter::class,
properties: [
'status' => 'exact',
'siteId' => 'exact',
'documentId' => 'exact',
'model' => 'exact',
]
)]
class Import
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
private ?int $id = null;
#[ORM\Column(length: 255)]
private ?string $model = null;
#[ORM\Column(length: 255)]
private ?string $status = null;
#[ORM\Column]
private ?\DateTimeImmutable $created_at = null;
#[ORM\Column(nullable: true)]
private ?\DateTimeImmutable $updated_at = null;
#[ORM\Column(type: Types::TEXT, nullable: true)]
private ?string $message = null;
#[ORM\Column(length: 255, nullable: true)]
private ?string $file = null;
#[ORM\Column(length: 255, nullable: true)]
private ?int $siteId = null;
#[ORM\Column(nullable: true)]
private array $params = [];
#[ORM\ManyToOne]
private ?User $user = null;
#[ORM\Column(length: 255, nullable: true)]
private ?int $documentId = null;
#[ORM\Column(type: Types::JSON, nullable: true)]
private ?array $import_summary = 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->created_at;
}
public function setCreatedAt(\DateTimeImmutable $created_at): self
{
$this->created_at = $created_at;
return $this;
}
public function getUpdatedAt(): ?\DateTimeImmutable
{
return $this->updated_at;
}
public function setUpdatedAt(?\DateTimeImmutable $updated_at): self
{
$this->updated_at = $updated_at;
return $this;
}
public function getMessage(): ?string
{
return $this->message;
}
public function setMessage(?string $message): self
{
$this->message = $message;
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;
}
public function getUser(): ?User
{
return $this->user;
}
public function setUser(?User $user): self
{
$this->user = $user;
return $this;
}
/**
* @return int|null
*/
public function getSiteId(): ?int
{
return $this->siteId;
}
/**
* @param int|null $siteId
*/
public function setSiteId(?int $siteId): void
{
$this->siteId = $siteId;
}
/**
* @return int|null
*/
public function getDocumentId(): ?int
{
return $this->documentId;
}
/**
* @param int|null $documentId
*/
public function setDocumentId(?int $documentId): void
{
$this->documentId = $documentId;
}
public function getImportSummary(): ?array
{
return $this->import_summary;
}
public function setImportSummary(?array $import_summary): self
{
$this->import_summary = $import_summary;
return $this;
}
}