134 lines
2.6 KiB
PHP
134 lines
2.6 KiB
PHP
<?php
|
|
|
|
namespace App\Entity;
|
|
|
|
use App\ImageType;
|
|
use App\Repository\ImageRepository;
|
|
use Doctrine\DBAL\Types\Types;
|
|
use Doctrine\ORM\Mapping as ORM;
|
|
|
|
#[ORM\Entity(repositoryClass: ImageRepository::class)]
|
|
#[ORM\Table(name: 'immagine')]
|
|
class Image implements \JsonSerializable
|
|
{
|
|
#[ORM\Id]
|
|
#[ORM\GeneratedValue]
|
|
#[ORM\Column]
|
|
private ?int $id = null;
|
|
|
|
#[ORM\Column(length: 255)]
|
|
private ?string $filename = null;
|
|
|
|
#[ORM\Column(name: 'didascalia', length: 255, nullable: true)]
|
|
private ?string $caption = null;
|
|
|
|
#[ORM\Column(name: 'autore', length: 255, nullable: true)]
|
|
private ?string $author = null;
|
|
|
|
#[ORM\Column(name: 'sito', type: Types::BIGINT, nullable: true)]
|
|
private ?string $site = null;
|
|
|
|
#[ORM\Column(name: 'ordine', type: Types::SMALLINT)]
|
|
private ?int $sequence = null;
|
|
|
|
#[ORM\Column(name: 'tipo')]
|
|
private ?string $type = null;
|
|
|
|
public function getId(): ?int
|
|
{
|
|
return $this->id;
|
|
}
|
|
|
|
public function setId(int $id): static
|
|
{
|
|
$this->id = $id;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function getFilename(): ?string
|
|
{
|
|
return $this->filename;
|
|
}
|
|
|
|
public function setFilename(string $filename): static
|
|
{
|
|
$this->filename = $filename;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function getCaption(): ?string
|
|
{
|
|
return $this->caption;
|
|
}
|
|
|
|
public function setCaption(?string $caption): static
|
|
{
|
|
$this->caption = $caption;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function getAuthor(): ?string
|
|
{
|
|
return $this->author;
|
|
}
|
|
|
|
public function setAuthor(?string $author): static
|
|
{
|
|
$this->author = $author;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function getSite(): ?string
|
|
{
|
|
return $this->site;
|
|
}
|
|
|
|
public function setSite(?string $site): static
|
|
{
|
|
$this->site = $site;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function getSequence(): ?int
|
|
{
|
|
return $this->sequence;
|
|
}
|
|
|
|
public function setSequence(int $sequence): static
|
|
{
|
|
$this->sequence = $sequence;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function getType(): string
|
|
{
|
|
$type = ImageType::from($this->type);
|
|
|
|
return $type->name;
|
|
}
|
|
|
|
public function setType(ImageType $type): static
|
|
{
|
|
$this->type = $type->value;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function jsonSerialize(): array
|
|
{
|
|
return [
|
|
'id' => $this->id,
|
|
'filename' => $this->filename,
|
|
'caption' => $this->caption,
|
|
'author' => $this->author,
|
|
'type' => $this->getType(),
|
|
];
|
|
}
|
|
}
|