Add image type + NotConserved
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Entity;
|
||||
|
||||
use App\ImageType;
|
||||
use App\Repository\ImageRepository;
|
||||
use Doctrine\DBAL\Types\Types;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
@@ -30,6 +31,9 @@ class Image implements \JsonSerializable
|
||||
#[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;
|
||||
@@ -102,6 +106,20 @@ class Image implements \JsonSerializable
|
||||
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 [
|
||||
@@ -109,6 +127,7 @@ class Image implements \JsonSerializable
|
||||
'filename' => $this->filename,
|
||||
'caption' => $this->caption,
|
||||
'author' => $this->author,
|
||||
'type' => $this->getType(),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user