<?php
namespace App\Entity;
use App\Repository\ParameterRepository;
use App\Traits\DateTrait;
use DateTime;
use Doctrine\ORM\Mapping as ORM;
use JMS\Serializer\Annotation as Serializer;
use JMS\Serializer\Annotation\Expose;
use JMS\Serializer\Annotation\Groups;
use Symfony\Component\HttpFoundation\File\File;
use Symfony\Component\HttpFoundation\File\UploadedFile;
use Vich\UploaderBundle\Mapping\Annotation as Vich;
/**
* @ORM\Entity(repositoryClass=ParameterRepository::class)
* @ORM\HasLifecycleCallbacks()
*
* @Serializer\ExclusionPolicy("ALL")
*
* @Vich\Uploadable
*/
class Parameter
{
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*
* @Expose
* @Groups({"parameter"})
*/
private ?int $id = NULL;
/**
* @ORM\Column(type="string", length=16)
*
* @Expose
* @Groups({"parameter"})
*/
private string $slug;
/**
* @ORM\Column(type="text", nullable=true)
*/
private ?string $value;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*
* @Expose
* @Groups({"parameter"})
*/
private ?string $title;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*
* @Expose
* @Groups({"parameter"})
*/
private ?string $fileName;
/**
* @Vich\UploadableField(mapping="general_documents", fileNameProperty="fileName")
*/
private ?File $file;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private ?string $originalName;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*
* @Expose
* @Groups({"parameter"})
*/
private ?string $externLink;
/**
* @deprecated
* @ORM\Column(type="boolean", nullable=true)
*/
private ?bool $noFooter;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private ?string $displayRole;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private ?string $displayJob;
/**
* @ORM\ManyToOne(targetEntity=ParameterHook::class, inversedBy="parameters")
*
* @Expose
* @Groups({"parameter"})
*/
private ?ParameterHook $parameterHook;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $thumbnail;
// Vich Uploader
/**
* @Vich\UploadableField(mapping="parameter_thumbnail", fileNameProperty="thumbnail")
* @var File
*/
private $thumbnailFile;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $displayUniverses;
/**
* @ORM\ManyToOne(targetEntity=User::class, inversedBy="relatedParameters")
*
* @Expose
* @Groups({"parameter"})
*/
private $userRelated;
/**
* @ORM\Column(type="boolean", nullable=true)
*/
private $public;
/**
* @ORM\Column(type="string", length=16, nullable=true)
*/
private $display;
use DateTrait;
public function getFile(): ?File
{
return $this->file ?? null;
}
public function setFile(File $file = NULL): void
{
$this->file = $file;
if ($file) {
$this->updatedAt = new DateTime('now');
}
}
public function getId(): ?int
{
return $this->id;
}
public function getSlug(): ?string
{
return $this->slug ?? null ;
}
public function setSlug(string $slug): self
{
$this->slug = $slug;
return $this;
}
public function getValue(): ?string
{
return $this->value ?? null;
}
public function setValue(?string $value): self
{
$this->value = $value;
return $this;
}
public function getTitle(): ?string
{
return $this->title ?? null;
}
public function setTitle(?string $title): self
{
$this->title = $title;
return $this;
}
public function getFileName(): ?string
{
return $this->fileName ?? null;
}
public function setFileName(?string $fileName): self
{
$this->fileName = $fileName;
return $this;
}
public function getOriginalName(): ?string
{
return $this->originalName ?? null;
}
public function setOriginalName(?string $originalName): self
{
$this->originalName = $originalName;
return $this;
}
public function getExternLink(): ?string
{
return $this->externLink ?? null;
}
public function setExternLink(?string $externLink): self
{
$this->externLink = $externLink;
return $this;
}
public function getNoFooter(): ?bool
{
return $this->noFooter;
}
public function setNoFooter(?bool $noFooter): self
{
$this->noFooter = $noFooter;
return $this;
}
public function getDisplayRole(): ?array
{
if ($this->displayRole === NULL) {
return NULL;
}
return explode(';', $this->displayRole);
}
public function setDisplayRole(?array $displayRole): self
{
if ($displayRole === []) {
$this->displayRole = NULL;
} else {
$this->displayRole = implode(';', $displayRole);
}
return $this;
}
public function getDisplayJob(): ?array
{
if ($this->displayJob === NULL) {
return NULL;
}
return explode(';', $this->displayJob);
}
public function setDisplayJob(?array $displayJob): self
{
if ($displayJob === []) {
$this->displayJob = NULL;
} else {
$this->displayJob = implode(';', $displayJob);
}
return $this;
}
public function getParameterHook(): ?ParameterHook
{
return $this->parameterHook;
}
public function setParameterHook(?ParameterHook $parameterHook): self
{
$this->parameterHook = $parameterHook;
return $this;
}
public function getThumbnail(): ?string
{
return $this->thumbnail;
}
public function setThumbnail(?string $thumbnail): self
{
$this->thumbnail = $thumbnail;
return $this;
}
public function getThumbnailFile(): ?File
{
return $this->thumbnailFile ?? null;
}
/**
* @param File|UploadedFile|null $thumbnailFile
*/
public function setThumbnailFile( File $thumbnailFile ): void
{
$this->thumbnailFile = $thumbnailFile;
if ( NULL !== $thumbnailFile ) {
// It is required that at least one field changes if you are using doctrine
// otherwise the event listeners won't be called and the file is lost
$this->updatedAt = new DateTime();
}
}
public function getDisplayUniverses(): ?array
{
if ($this->displayUniverses === NULL) {
return NULL;
}
return explode(';', $this->displayUniverses);
}
public function setDisplayUniverses(?array $displayUniverses): self
{
if ($displayUniverses === []) {
$this->displayUniverses = NULL;
} else {
$this->displayUniverses = implode(';', $displayUniverses);
}
return $this;
}
public function getUserRelated(): ?User
{
return $this->userRelated;
}
public function setUserRelated(?User $userRelated): self
{
$this->userRelated = $userRelated;
return $this;
}
public function isPublic(): ?bool
{
return $this->public ?? FALSE;
}
public function setPublic(?bool $public): self
{
$this->public = $public;
return $this;
}
public function getDisplay(): ?string
{
return $this->display;
}
public function setDisplay(?string $display): self
{
$this->display = $display;
return $this;
}
}