src/Entity/Parameter.php line 24

Open in your IDE?
  1. <?php
  2.     namespace App\Entity;
  3.     use App\Repository\ParameterRepository;
  4.     use App\Traits\DateTrait;
  5.     use DateTime;
  6.     use Doctrine\ORM\Mapping as ORM;
  7.     use JMS\Serializer\Annotation as Serializer;
  8.     use JMS\Serializer\Annotation\Expose;
  9.     use JMS\Serializer\Annotation\Groups;
  10.     use Symfony\Component\HttpFoundation\File\File;
  11.     use Symfony\Component\HttpFoundation\File\UploadedFile;
  12.     use Vich\UploaderBundle\Mapping\Annotation as Vich;
  13.     /**
  14.      * @ORM\Entity(repositoryClass=ParameterRepository::class)
  15.      * @ORM\HasLifecycleCallbacks()
  16.      *
  17.      * @Serializer\ExclusionPolicy("ALL")
  18.      *
  19.      * @Vich\Uploadable
  20.      */
  21.     class Parameter
  22.     {
  23.         /**
  24.          * @ORM\Id
  25.          * @ORM\GeneratedValue
  26.          * @ORM\Column(type="integer")
  27.          *
  28.          * @Expose
  29.          * @Groups({"parameter"})
  30.          */
  31.         private ?int $id NULL;
  32.         /**
  33.          * @ORM\Column(type="string", length=16)
  34.          *
  35.          * @Expose
  36.          * @Groups({"parameter"})
  37.          */
  38.         private string $slug;
  39.         /**
  40.          * @ORM\Column(type="text", nullable=true)
  41.          */
  42.         private ?string $value;
  43.         /**
  44.          * @ORM\Column(type="string", length=255, nullable=true)
  45.          *
  46.          * @Expose
  47.          * @Groups({"parameter"})
  48.          */
  49.         private ?string $title;
  50.         /**
  51.          * @ORM\Column(type="string", length=255, nullable=true)
  52.          *
  53.          * @Expose
  54.          * @Groups({"parameter"})
  55.          */
  56.         private ?string $fileName;
  57.         /**
  58.          * @Vich\UploadableField(mapping="general_documents", fileNameProperty="fileName")
  59.          */
  60.         private ?File $file;
  61.         /**
  62.          * @ORM\Column(type="string", length=255, nullable=true)
  63.          */
  64.         private ?string $originalName;
  65.         /**
  66.          * @ORM\Column(type="string", length=255, nullable=true)
  67.          *
  68.          * @Expose
  69.          * @Groups({"parameter"})
  70.          */
  71.         private ?string $externLink;
  72.         /**
  73.          * @deprecated
  74.          * @ORM\Column(type="boolean", nullable=true)
  75.          */
  76.         private ?bool $noFooter;
  77.         /**
  78.          * @ORM\Column(type="string", length=255, nullable=true)
  79.          */
  80.         private ?string $displayRole;
  81.         /**
  82.          * @ORM\Column(type="string", length=255, nullable=true)
  83.          */
  84.         private ?string $displayJob;
  85.         /**
  86.          * @ORM\ManyToOne(targetEntity=ParameterHook::class, inversedBy="parameters")
  87.          *
  88.          * @Expose
  89.          * @Groups({"parameter"})
  90.          */
  91.         private ?ParameterHook $parameterHook;
  92.         /**
  93.          * @ORM\Column(type="string", length=255, nullable=true)
  94.          */
  95.         private $thumbnail;
  96.         // Vich Uploader
  97.         /**
  98.          * @Vich\UploadableField(mapping="parameter_thumbnail", fileNameProperty="thumbnail")
  99.          * @var File
  100.          */
  101.         private $thumbnailFile;
  102.         /**
  103.          * @ORM\Column(type="string", length=255, nullable=true)
  104.          */
  105.         private $displayUniverses;
  106.         /**
  107.          * @ORM\ManyToOne(targetEntity=User::class, inversedBy="relatedParameters")
  108.          *
  109.          * @Expose
  110.          * @Groups({"parameter"})
  111.          */
  112.         private $userRelated;
  113.         /**
  114.          * @ORM\Column(type="boolean", nullable=true)
  115.          */
  116.         private $public;
  117.         /**
  118.          * @ORM\Column(type="string", length=16, nullable=true)
  119.          */
  120.         private $display;
  121.         use DateTrait;
  122.         public function getFile(): ?File
  123.         {
  124.             return $this->file ?? null;
  125.         }
  126.         public function setFile(File $file NULL): void
  127.         {
  128.             $this->file $file;
  129.             if ($file) {
  130.                 $this->updatedAt = new DateTime('now');
  131.             }
  132.         }
  133.         public function getId(): ?int
  134.         {
  135.             return $this->id;
  136.         }
  137.         public function getSlug(): ?string
  138.         {
  139.             return $this->slug ?? null ;
  140.         }
  141.         public function setSlug(string $slug): self
  142.         {
  143.             $this->slug $slug;
  144.             return $this;
  145.         }
  146.         public function getValue(): ?string
  147.         {
  148.             return $this->value ?? null;
  149.         }
  150.         public function setValue(?string $value): self
  151.         {
  152.             $this->value $value;
  153.             return $this;
  154.         }
  155.         public function getTitle(): ?string
  156.         {
  157.             return $this->title ?? null;
  158.         }
  159.         public function setTitle(?string $title): self
  160.         {
  161.             $this->title $title;
  162.             return $this;
  163.         }
  164.         public function getFileName(): ?string
  165.         {
  166.             return $this->fileName ?? null;
  167.         }
  168.         public function setFileName(?string $fileName): self
  169.         {
  170.             $this->fileName $fileName;
  171.             return $this;
  172.         }
  173.         public function getOriginalName(): ?string
  174.         {
  175.             return $this->originalName ?? null;
  176.         }
  177.         public function setOriginalName(?string $originalName): self
  178.         {
  179.             $this->originalName $originalName;
  180.             return $this;
  181.         }
  182.         public function getExternLink(): ?string
  183.         {
  184.             return $this->externLink ?? null;
  185.         }
  186.         public function setExternLink(?string $externLink): self
  187.         {
  188.             $this->externLink $externLink;
  189.             return $this;
  190.         }
  191.         public function getNoFooter(): ?bool
  192.         {
  193.             return $this->noFooter;
  194.         }
  195.         public function setNoFooter(?bool $noFooter): self
  196.         {
  197.             $this->noFooter $noFooter;
  198.             return $this;
  199.         }
  200.         public function getDisplayRole(): ?array
  201.         {
  202.             if ($this->displayRole === NULL) {
  203.                 return NULL;
  204.             }
  205.             return explode(';'$this->displayRole);
  206.         }
  207.         public function setDisplayRole(?array $displayRole): self
  208.         {
  209.             if ($displayRole === []) {
  210.                 $this->displayRole NULL;
  211.             } else {
  212.                 $this->displayRole implode(';'$displayRole);
  213.             }
  214.             return $this;
  215.         }
  216.         public function getDisplayJob(): ?array
  217.         {
  218.             if ($this->displayJob === NULL) {
  219.                 return NULL;
  220.             }
  221.             return explode(';'$this->displayJob);
  222.         }
  223.         public function setDisplayJob(?array $displayJob): self
  224.         {
  225.             if ($displayJob === []) {
  226.                 $this->displayJob NULL;
  227.             } else {
  228.                 $this->displayJob implode(';'$displayJob);
  229.             }
  230.             return $this;
  231.         }
  232.         public function getParameterHook(): ?ParameterHook
  233.         {
  234.             return $this->parameterHook;
  235.         }
  236.         public function setParameterHook(?ParameterHook $parameterHook): self
  237.         {
  238.             $this->parameterHook $parameterHook;
  239.             return $this;
  240.         }
  241.         public function getThumbnail(): ?string
  242.         {
  243.             return $this->thumbnail;
  244.         }
  245.         public function setThumbnail(?string $thumbnail): self
  246.         {
  247.             $this->thumbnail $thumbnail;
  248.             return $this;
  249.         }
  250.         public function getThumbnailFile(): ?File
  251.         {
  252.             return $this->thumbnailFile ?? null;
  253.         }
  254.         /**
  255.          * @param File|UploadedFile|null $thumbnailFile
  256.          */
  257.         public function setThumbnailFileFile $thumbnailFile ): void
  258.         {
  259.             $this->thumbnailFile $thumbnailFile;
  260.             if ( NULL !== $thumbnailFile ) {
  261.                 // It is required that at least one field changes if you are using doctrine
  262.                 // otherwise the event listeners won't be called and the file is lost
  263.                 $this->updatedAt = new DateTime();
  264.             }
  265.         }
  266.         public function getDisplayUniverses(): ?array
  267.         {
  268.             if ($this->displayUniverses === NULL) {
  269.                 return NULL;
  270.             }
  271.             return explode(';'$this->displayUniverses);
  272.         }
  273.         public function setDisplayUniverses(?array $displayUniverses): self
  274.         {
  275.             if ($displayUniverses === []) {
  276.                 $this->displayUniverses NULL;
  277.             } else {
  278.                 $this->displayUniverses implode(';'$displayUniverses);
  279.             }
  280.             return $this;
  281.         }
  282.         public function getUserRelated(): ?User
  283.         {
  284.             return $this->userRelated;
  285.         }
  286.         public function setUserRelated(?User $userRelated): self
  287.         {
  288.             $this->userRelated $userRelated;
  289.             return $this;
  290.         }
  291.         public function isPublic(): ?bool
  292.         {
  293.             return $this->public ?? FALSE;
  294.         }
  295.         public function setPublic(?bool $public): self
  296.         {
  297.             $this->public $public;
  298.             return $this;
  299.         }
  300.         public function getDisplay(): ?string
  301.         {
  302.             return $this->display;
  303.         }
  304.         public function setDisplay(?string $display): self
  305.         {
  306.             $this->display $display;
  307.             return $this;
  308.         }
  309.     }