<?php
namespace App\Entity;
use App\Repository\AdvertisingRepository;
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 Vich\UploaderBundle\Mapping\Annotation as Vich;
/**
* @ORM\Entity(repositoryClass=AdvertisingRepository::class)
*
* @Serializer\ExclusionPolicy("ALL")
* @Vich\Uploadable
*/
class Advertising
{
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*
* @Expose
* @Groups({"advertising"})
*/
private $id;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*
* @Expose
* @Groups({"advertising"})
*/
private $path;
// Vich Uploader
/**
* @Vich\UploadableField(mapping="advertising_images", fileNameProperty="path")
* @var File
*/
private $imageFile;
// /**
// * @Assert\File(maxSize="6000000")
// */
// private $file;
// /**
// * @ORM\Column(type="datetime", nullable=true)
// */
// private $uploadDate;
/**
* @ORM\Column(type="string", length=512, nullable=true)
*
* @Expose
* @Groups({"advertising"})
*/
private $targetURI;
/**
* @ORM\Column(type="boolean", options={"default":false})
*
* @Expose
* @Groups({"advertising"})
*/
private $inNewTab = FALSE;
/**
* @ORM\Column(type="boolean", options={"default":false})
*
* @Expose
* @Groups({"advertising"})
*/
private $isDefault;
/**
* @ORM\Column(type="string", length=10, nullable=true)
*
* @Expose
* @Groups({"advertising"})
*/
private $locale;
/**
* @ORM\Column(type="text", nullable=true)
*
* @Expose
* @Groups({"advertising"})
*/
private $caption;
// private $rootdir;
use DateTrait;
public function __construct()
{
// if (!file_exists($this->getUploadRootDir())) {
// mkdir($this->getUploadRootDir(), 0777, TRUE);
// }
$this->isDefault = FALSE;
}
/*
* ============================================================================================
* =============================== FONCTIONS CUSTOM ===========================================
* ============================================================================================
*/
public function getImageFile(): File
{
return $this->imageFile;
}
public function setImageFile(File $imageFile): Advertising
{
$this->imageFile = $imageFile;
if (NULL !== $imageFile) {
// 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();
}
return $this;
}
public function getId(): ?int
{
return $this->id;
}
public function getPath(): ?string
{
return $this->path;
}
public function setPath(?string $path): self
{
$this->path = $path;
return $this;
}
public function getTargetURI(): ?string
{
return $this->targetURI;
}
public function setTargetURI(?string $targetURI): self
{
$this->targetURI = $targetURI;
return $this;
}
public function getInNewTab(): ?bool
{
return $this->inNewTab;
}
public function setInNewTab(bool $inNewTab): self
{
$this->inNewTab = $inNewTab;
return $this;
}
public function getIsDefault(): ?bool
{
return $this->isDefault;
}
public function setIsDefault(bool $isDefault): self
{
$this->isDefault = $isDefault;
return $this;
}
public function getLocale(): ?string
{
return $this->locale;
}
public function setLocale(?string $locale): self
{
$this->locale = $locale;
return $this;
}
public function getCaption(): ?string
{
return $this->caption;
}
public function setCaption(?string $caption): self
{
$this->caption = $caption;
return $this;
}
}