src/Entity/Behind.php line 26

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\BehindRepository;
  4. use Doctrine\ORM\Mapping as ORM;
  5. use Gedmo\Mapping\Annotation as Gedmo;
  6. use Gedmo\SoftDeleteable\Traits\SoftDeleteableEntity;
  7. use Gedmo\Timestampable\Traits\TimestampableEntity;
  8. use Gedmo\Translatable\Translatable;
  9. use Doctrine\Common\Collections\ArrayCollection;
  10. use App\Entity\Translation\BehindTranslation;
  11. use Symfony\Component\HttpFoundation\File\File;
  12. use Symfony\Component\HttpFoundation\File\UploadedFile;
  13. use Symfony\Component\Serializer\Annotation\Ignore;
  14. use Symfony\Component\Serializer\Annotation\Groups;
  15. use Symfony\Component\Validator\Constraints as Assert;
  16. use Vich\UploaderBundle\Mapping\Annotation as Vich;
  17. /**
  18.  * @ORM\Entity(repositoryClass=BehindRepository::class)
  19.  * @Gedmo\TranslationEntity(class="App\Entity\Translation\BehindTranslation")
  20.  * @Gedmo\SoftDeleteable(fieldName="deletedAt", timeAware=false, hardDelete=true)
  21.  * @Vich\Uploadable
  22.  */
  23. class Behind implements Translatable
  24. {
  25.     use TimestampableEntity;
  26.     use SetTranslationsTrait;
  27.     public const FIELDS = [
  28.         'title'
  29.     ];
  30.     /**
  31.      * @ORM\Id
  32.      * @ORM\GeneratedValue
  33.      * @ORM\Column(type="integer")
  34.      * @Groups("behind:list", "behind:item")
  35.      */
  36.     private $id;
  37.     /**
  38.      * @ORM\Column(type="string")
  39.      * @Groups({"behind:list", "behind:item"})
  40.      * @var string|null
  41.      *
  42.      */
  43.     private $imageName;
  44.     /**
  45.      * @ORM\Column(type="integer")
  46.      *
  47.      * @var int|null
  48.      * @Ignore()
  49.      */
  50.     private $imageSize;
  51.     /**
  52.      * @Assert\File(
  53.      *     mimeTypes = {"image/jpeg", "image/gif", "image/png", "image/jpg"},
  54.      *     mimeTypesMessage = "Wrong file type (jpeg,gif,png,jpg)"
  55.      * )
  56.      * @Vich\UploadableField(mapping="behind", fileNameProperty="imageName", size="imageSize")
  57.      * @var File|null
  58.      * @Ignore()
  59.      */
  60.     private $imageFile;
  61.     /**
  62.      * @ORM\Column(type="string", length=255)
  63.      * @Gedmo\Translatable
  64.      * @Groups("behind:list", "behind:item")
  65.      */
  66.     private $title;
  67.     /**
  68.      * @var string
  69.      * @Ignore()
  70.      */
  71.     private $titleEn;
  72.     /**
  73.      * @var string
  74.      * @Ignore()
  75.      */
  76.     private $titleCa;
  77.     /**
  78.      * @ORM\Column(type="string", length=255)
  79.      * @Groups("behind:list", "behind:item")
  80.      */
  81.     private $url;
  82.     /**
  83.     * @ORM\OneToMany(
  84.     *   targetEntity="App\Entity\Translation\BehindTranslation",
  85.     *   mappedBy="object",
  86.     *   cascade={"persist", "remove"}
  87.     * )
  88.      * @Ignore()
  89.     */
  90.     private $translations;
  91.     /**
  92.      * @ORM\Column(type="datetime", nullable=true)
  93.      * @var \DateTime|null
  94.      */
  95.     protected $deletedAt;
  96.     /**
  97.      * Set or clear the deleted at timestamp.
  98.      *
  99.      * @return self
  100.      */
  101.     public function setDeletedAt(\DateTime $deletedAt null)
  102.     {
  103.         $this->deletedAt $deletedAt;
  104.         return $this;
  105.     }
  106.     /**
  107.      * Get the deleted at timestamp value. Will return null if
  108.      * the entity has not been soft deleted.
  109.      *
  110.      * @return \DateTime|null
  111.      */
  112.     public function getDeletedAt()
  113.     {
  114.         return $this->deletedAt;
  115.     }
  116.     /**
  117.     * Behind constructor.
  118.     */
  119.     public function __construct()
  120.     {
  121.         $this->translations = new ArrayCollection();
  122.     }
  123.     public function getId(): ?int
  124.     {
  125.         return $this->id;
  126.     }
  127.     public function getTitle(): ?string
  128.     {
  129.         return $this->title;
  130.     }
  131.     public function setTitle(string $title): self
  132.     {
  133.         $this->title $title;
  134.         return $this;
  135.     }
  136.     /**
  137.      * @return mixed
  138.      */
  139.     public function getTitleEn()
  140.     {
  141.         return $this->titleEn;
  142.     }
  143.     /**
  144.      * @param string|null $titleEn
  145.      *
  146.      * @return $this
  147.      */
  148.     public function setTitleEn(?string $titleEn): self
  149.     {
  150.         $this->titleEn $titleEn;
  151.         return $this;
  152.     }
  153.     /**
  154.      * @return mixed
  155.      */
  156.     public function getTitleCa()
  157.     {
  158.         return $this->titleCa;
  159.     }
  160.     /**
  161.      * @param string|null $titleCa
  162.      *
  163.      * @return $this
  164.      */
  165.     public function setTitleCa(?string $titleCa): self
  166.     {
  167.         $this->titleCa $titleCa;
  168.         return $this;
  169.     }
  170.     /**
  171.      * @return mixed
  172.      */
  173.     public function getUrl()
  174.     {
  175.         return $this->url;
  176.     }
  177.     /**
  178.      * @param mixed $url
  179.      */
  180.     public function setUrl($url): void
  181.     {
  182.         $this->url $url;
  183.     }
  184.     /**
  185.      * @Gedmo\Locale
  186.      * Used locale to override Translation listener`s locale
  187.      * this is not a mapped field of entity metadata, just a simple property
  188.      */
  189.     private $locale;
  190.     public function setTranslatableLocale($locale)
  191.     {
  192.         $this->locale $locale;
  193.     }
  194.     public function getTranslations()
  195.     {
  196.         return $this->translations;
  197.     }
  198.     public function addTranslation(BehindTranslation $t)
  199.     {
  200.         if (!$this->translations->contains($t)) {
  201.             $this->translations[] = $t;
  202.             $t->setObject($this);
  203.         }
  204.     }
  205.     /**
  206.      * @param File|UploadedFile|null $thumbnailFile
  207.      */
  208.     public function setImageFile(?File $thumbnailFile null): void
  209.     {
  210.         $this->imageFile $thumbnailFile;
  211.         if (null !== $thumbnailFile) {
  212.             $this->updatedAt = new \DateTimeImmutable();
  213.         }
  214.     }
  215.     public function getImageFile(): ?File
  216.     {
  217.         return $this->imageFile;
  218.     }
  219.     public function setImageName(?string $imageName): void
  220.     {
  221.         $this->imageName $imageName;
  222.     }
  223.     public function getImageName(): ?string
  224.     {
  225.         return $this->imageName;
  226.     }
  227.     public function setImageSize(?int $imageSize): void
  228.     {
  229.         $this->imageSize $imageSize;
  230.     }
  231.     public function getImageSize(): ?int
  232.     {
  233.         return $this->imageSize;
  234.     }
  235. }