src/Entity/Advertising.php line 22

Open in your IDE?
  1. <?php
  2.     namespace App\Entity;
  3.     use App\Repository\AdvertisingRepository;
  4.     use App\Traits\DateTrait;
  5.     use DateTimeImmutable;
  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=AdvertisingRepository::class)
  15.      *
  16.      * @Serializer\ExclusionPolicy("ALL")
  17.      * @Vich\Uploadable
  18.      */
  19.     class Advertising
  20.     {
  21.         /**
  22.          * @ORM\Id
  23.          * @ORM\GeneratedValue
  24.          * @ORM\Column(type="integer")
  25.          *
  26.          * @Expose
  27.          * @Groups({"advertising"})
  28.          */
  29.         private $id;
  30.         /**
  31.          * @ORM\Column(type="string", length=255, nullable=true)
  32.          *
  33.          * @Expose
  34.          * @Groups({"advertising"})
  35.          */
  36.         private $path;
  37.         // Vich Uploader
  38.         /**
  39.          * @Vich\UploadableField(mapping="advertising_images", fileNameProperty="path")
  40.          * @var File
  41.          */
  42.         private $imageFile;
  43. //        /**
  44. //         * @Assert\File(maxSize="6000000")
  45. //         */
  46. //        private $file;
  47. //        /**
  48. //         * @ORM\Column(type="datetime", nullable=true)
  49. //         */
  50. //        private $uploadDate;
  51.         /**
  52.          * @ORM\Column(type="string", length=512, nullable=true)
  53.          *
  54.          * @Expose
  55.          * @Groups({"advertising"})
  56.          */
  57.         private $targetURI;
  58.         /**
  59.          * @ORM\Column(type="boolean", options={"default":false})
  60.          *
  61.          * @Expose
  62.          * @Groups({"advertising"})
  63.          */
  64.         private $inNewTab FALSE;
  65.         /**
  66.          * @ORM\Column(type="boolean", options={"default":false})
  67.          *
  68.          * @Expose
  69.          * @Groups({"advertising"})
  70.          */
  71.         private $isDefault;
  72.         /**
  73.          * @ORM\Column(type="string", length=10, nullable=true)
  74.          *
  75.          * @Expose
  76.          * @Groups({"advertising"})
  77.          */
  78.         private $locale;
  79.         /**
  80.          * @ORM\Column(type="text", nullable=true)
  81.          *
  82.          * @Expose
  83.          * @Groups({"advertising"})
  84.          */
  85.         private $caption;
  86. //        private $rootdir;
  87.         use DateTrait;
  88.         public function __construct()
  89.         {
  90. //            if (!file_exists($this->getUploadRootDir())) {
  91. //                mkdir($this->getUploadRootDir(), 0777, TRUE);
  92. //            }
  93.             $this->isDefault FALSE;
  94.         }
  95.         /*
  96.          * ============================================================================================
  97.          * =============================== FONCTIONS CUSTOM ===========================================
  98.          * ============================================================================================
  99.          */
  100.         public function getImageFile()
  101.         {
  102.             return $this->imageFile;
  103.         }
  104.         /**
  105.          * @param File|UploadedFile|null $imageFile
  106.          */
  107.         public function setImageFileFile $imageFile ): void
  108.         {
  109.             $this->imageFile $imageFile;
  110.             if ( NULL !== $imageFile ) {
  111.                 // It is required that at least one field changes if you are using doctrine
  112.                 // otherwise the event listeners won't be called and the file is lost
  113.                 $this->updatedAt = new DateTimeImmutable();
  114.             }
  115.         }
  116.         public function getId(): ?int
  117.         {
  118.             return $this->id;
  119.         }
  120.         public function getPath(): ?string
  121.         {
  122.             return $this->path;
  123.         }
  124.         public function setPath( ?string $path ): self
  125.         {
  126.             $this->path $path;
  127.             return $this;
  128.         }
  129.         public function getTargetURI(): ?string
  130.         {
  131.             return $this->targetURI;
  132.         }
  133.         public function setTargetURI( ?string $targetURI ): self
  134.         {
  135.             $this->targetURI $targetURI;
  136.             return $this;
  137.         }
  138.         public function getInNewTab(): ?bool
  139.         {
  140.             return $this->inNewTab;
  141.         }
  142.         public function setInNewTabbool $inNewTab ): self
  143.         {
  144.             $this->inNewTab $inNewTab;
  145.             return $this;
  146.         }
  147.         public function getIsDefault(): ?bool
  148.         {
  149.             return $this->isDefault;
  150.         }
  151.         public function setIsDefaultbool $isDefault ): self
  152.         {
  153.             $this->isDefault $isDefault;
  154.             return $this;
  155.         }
  156.         public function getLocale(): ?string
  157.         {
  158.             return $this->locale;
  159.         }
  160.         public function setLocale( ?string $locale ): self
  161.         {
  162.             $this->locale $locale;
  163.             return $this;
  164.         }
  165.         public function getCaption(): ?string
  166.         {
  167.             return $this->caption;
  168.         }
  169.         public function setCaption( ?string $caption ): self
  170.         {
  171.             $this->caption $caption;
  172.             return $this;
  173.         }
  174.     }