src/Entity/BannerSponsorClassification.php line 26

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\BannerSponsorClassificationRepository;
  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 Symfony\Component\HttpFoundation\File\File;
  10. use Symfony\Component\HttpFoundation\File\UploadedFile;
  11. use Symfony\Component\Serializer\Annotation\Groups;
  12. use Symfony\Component\Serializer\Annotation\Ignore;
  13. use Vich\UploaderBundle\Mapping\Annotation as Vich;
  14. use Doctrine\Common\Collections\ArrayCollection;
  15. use App\Entity\Translation\BannerSponsorClassificationTranslation;
  16. use Symfony\Component\Validator\Constraints as Assert;
  17. /**
  18.  * @ORM\Entity(repositoryClass=BannerSponsorClassificationRepository::class)
  19.  * @Gedmo\SoftDeleteable(fieldName="deletedAt", timeAware=false,hardDelete=false)
  20.  * @Gedmo\TranslationEntity(class="App\Entity\Translation\BannerSponsorClassificationTranslation")
  21.  * @Vich\Uploadable
  22.  */
  23. class BannerSponsorClassification implements Translatable
  24. {
  25.     use TimestampableEntity;
  26.     use SetTranslationsTrait;
  27.     public const FIELDS = [
  28.         'title',
  29.         'url'
  30.     ];
  31.     public const FIELDS_NO_FALLBACK = [
  32.         'url'
  33.     ];
  34.     /**
  35.      * @ORM\Id
  36.      * @ORM\GeneratedValue
  37.      * @ORM\Column(type="integer")
  38.      * @Groups("banner_classification:list", "banner_classification:item")
  39.      */
  40.     private $id;
  41.     /**
  42.      * @ORM\Column(type="string", length=255)
  43.      * @Gedmo\Translatable
  44.      * @Groups("banner_classification:list", "banner_classification:item")
  45.      */
  46.     private $title;
  47.     /**
  48.      * @var string
  49.      * @Ignore()
  50.      */
  51.     private $titleEn;
  52.     /**
  53.      * @var string
  54.      * @Ignore()
  55.      */
  56.     private $titleCa;
  57.     /**
  58.      * @ORM\Column(type="boolean")
  59.      * @Groups("banner_classification:list", "banner_classification:item")
  60.      */
  61.     private $enabled;
  62.     /**
  63.      * @ORM\Column(type="string", length=255, nullable=true)
  64.      * @Groups("banner_classification:list", "banner_classification:item")
  65.      */
  66.     private $navigate;
  67.     /**
  68.      * @var string
  69.      * @Groups("banner_classification:list", "banner_classification:item")
  70.      */
  71.     private $image;
  72.     /**
  73.      * @ORM\Column(type="string")
  74.      * @Groups("banner_classification:list", "banner_classification:item")
  75.      * @var string|null
  76.      *
  77.      */
  78.     private $imageName;
  79.     /**
  80.      * @ORM\Column(type="integer")
  81.      *
  82.      * @var int|null
  83.      * @Ignore()
  84.      */
  85.     private $imageSize;
  86.     /**
  87.      * @ORM\Column(type="string", length=255, nullable=true)
  88.      * @Groups("banner_classification:list", "banner_classification:item")
  89.      */
  90.     private $url;
  91.     /**
  92.      * @var string | null
  93.      * @Ignore()
  94.      */
  95.     private ?string $urlEn null;
  96.     /**
  97.      * @var string | null
  98.      * @Ignore()
  99.      */
  100.     private ?string $urlCa null;
  101.     /**
  102.     * @ORM\OneToMany(
  103.     *   targetEntity="App\Entity\Translation\BannerSponsorClassificationTranslation",
  104.     *   mappedBy="object",
  105.     *   cascade={"persist", "remove"}
  106.     * )
  107.      * @Ignore()
  108.     */
  109.     private $translations;
  110.     /**
  111.      * @Assert\File(
  112.      *     mimeTypes = {"image/jpeg", "image/gif", "image/png", "image/jpg"},
  113.      *     mimeTypesMessage = "Wrong file type (jpeg,gif,png,jpg)"
  114.      * )
  115.      * @Vich\UploadableField(mapping="banner", fileNameProperty="imageName", size="imageSize")
  116.      * @var File|null
  117.      * @Ignore()
  118.      */
  119.     private $imageFile;
  120.     /**
  121.      * @ORM\Column(type="datetime", nullable=true)
  122.      * @var \DateTime|null
  123.      */
  124.     protected $deletedAt;
  125.     /**
  126.      * @ORM\Column(type="string", length=255, nullable=true)
  127.      */
  128.     private $bannerType;
  129.     /**
  130.      * @ORM\Column(type="string", nullable=true)
  131.      * @Groups("banner:list", "banner:item")
  132.      * @var string|null
  133.      *
  134.      */
  135.     private $imageNameEn;
  136.     /**
  137.      * @ORM\Column(type="integer", nullable=true)
  138.      *
  139.      * @var int|null
  140.      * @Ignore()
  141.      */
  142.     private $imageSizeEn;
  143.     /**
  144.      * @Assert\File(
  145.      *     mimeTypes = {"image/jpeg", "image/gif", "image/png", "image/jpg"},
  146.      *     mimeTypesMessage = "Wrong file type (jpeg,gif,png,jpg)"
  147.      * )
  148.      * @Vich\UploadableField(mapping="banner", fileNameProperty="imageNameEn", size="imageSizeEn")
  149.      * @var File|null
  150.      * @Ignore()
  151.      */
  152.     private $imageFileEn;
  153.     /**
  154.      * @ORM\Column(type="string", nullable=true)
  155.      * @Groups("banner:list", "banner:item")
  156.      * @var string|null
  157.      *
  158.      */
  159.     private $imageNameCa;
  160.     /**
  161.      * @ORM\Column(type="integer", nullable=true)
  162.      *
  163.      * @var int|null
  164.      * @Ignore()
  165.      */
  166.     private $imageSizeCa;
  167.     /**
  168.      * @Assert\File(
  169.      *     mimeTypes = {"image/jpeg", "image/gif", "image/png", "image/jpg"},
  170.      *     mimeTypesMessage = "Wrong file type (jpeg,gif,png,jpg)"
  171.      * )
  172.      * @Vich\UploadableField(mapping="banner", fileNameProperty="imageNameCa", size="imageSizeCa")
  173.      * @var File|null
  174.      * @Ignore()
  175.      */
  176.     private $imageFileCa;
  177.     /**
  178.      * @ORM\Column(type="string", length=100, nullable=true)
  179.      */
  180.     private $buttonName;
  181.     /**
  182.      * Set or clear the deleted at timestamp.
  183.      *
  184.      * @return self
  185.      */
  186.     public function setDeletedAt(\DateTime $deletedAt null)
  187.     {
  188.         $this->deletedAt $deletedAt;
  189.         return $this;
  190.     }
  191.     /**
  192.      * Get the deleted at timestamp value. Will return null if
  193.      * the entity has not been soft deleted.
  194.      *
  195.      * @return \DateTime|null
  196.      */
  197.     public function getDeletedAt()
  198.     {
  199.         return $this->deletedAt;
  200.     }
  201.     /**
  202.      * Banner constructor.
  203.      */
  204.     public function __construct()
  205.     {
  206.         $this->image $this;
  207.         $this->enabled true;
  208.         $this->translations = new ArrayCollection();
  209.     }
  210.     public function getId(): ?int
  211.     {
  212.         return $this->id;
  213.     }
  214.     public function getTitle(): ?string
  215.     {
  216.         return $this->title;
  217.     }
  218.     public function setTitle(string $title): self
  219.     {
  220.         $this->title $title;
  221.         return $this;
  222.     }
  223.     /**
  224.      * @return mixed
  225.      */
  226.     public function getTitleEn()
  227.     {
  228.         return $this->titleEn;
  229.     }
  230.     /**
  231.      * @param string|null $titleEn
  232.      *
  233.      * @return $this
  234.      */
  235.     public function setTitleEn(?string $titleEn): self
  236.     {
  237.         $this->titleEn $titleEn;
  238.         return $this;
  239.     }
  240.     /**
  241.      * @return mixed
  242.      */
  243.     public function getTitleCa()
  244.     {
  245.         return $this->titleCa;
  246.     }
  247.     /**
  248.      * @param string|null $titleCa
  249.      *
  250.      * @return $this
  251.      */
  252.     public function setTitleCa(?string $titleCa): self
  253.     {
  254.         $this->titleCa $titleCa;
  255.         return $this;
  256.     }
  257.     public function getEnabled(): ?bool
  258.     {
  259.         return $this->enabled;
  260.     }
  261.     public function setEnabled(bool $enabled): self
  262.     {
  263.         $this->enabled $enabled;
  264.         return $this;
  265.     }
  266.     public function getNavigate(): ?string
  267.     {
  268.         return $this->navigate;
  269.     }
  270.     public function setNavigate(?string $navigate): self
  271.     {
  272.         $this->navigate $navigate;
  273.         return $this;
  274.     }
  275.     /**
  276.      * @Gedmo\Locale
  277.      * Used locale to override Translation listener`s locale
  278.      * this is not a mapped field of entity metadata, just a simple property
  279.      */
  280.     private $locale;
  281.     public function setTranslatableLocale($locale)
  282.     {
  283.         $this->locale $locale;
  284.     }
  285.     public function getUrl(): ?string
  286.     {
  287.         return $this->url;
  288.     }
  289.     public function setUrl(?string $url): self
  290.     {
  291.         $this->url $url;
  292.         return $this;
  293.     }
  294.     /**
  295.      * @param File|UploadedFile|null $imageFile
  296.      */
  297.     public function setImageFile(?File $imageFile null): void
  298.     {
  299.         $this->imageFile $imageFile;
  300.         if (null !== $imageFile) {
  301.             $this->updatedAt = new \DateTimeImmutable();
  302.         }
  303.     }
  304.     public function getImageFile(): ?File
  305.     {
  306.         return $this->imageFile;
  307.     }
  308.     public function setImageName(?string $imageName): void
  309.     {
  310.         $this->imageName $imageName;
  311.     }
  312.     public function getImageName(): ?string
  313.     {
  314.         return $this->imageName;
  315.     }
  316.     public function setImageSize(?int $imageSize): void
  317.     {
  318.         $this->imageSize $imageSize;
  319.     }
  320.     public function getImageSize(): ?int
  321.     {
  322.         return $this->imageSize;
  323.     }
  324.     public function getTranslations()
  325.     {
  326.         return $this->translations;
  327.     }
  328.     public function addTranslation(BannerSponsorClassificationTranslation $t)
  329.     {
  330.         if (!$this->translations->contains($t)) {
  331.             $this->translations[] = $t;
  332.             $t->setObject($this);
  333.         }
  334.     }
  335.     public function getBannerType(): ?string
  336.     {
  337.         return $this->bannerType ?? 'bannerClassification';
  338.     }
  339.     public function setBannerType(?string $bannerType): self
  340.     {
  341.         $this->bannerType $bannerType;
  342.         return $this;
  343.     }
  344.     /**
  345.      * @param File|UploadedFile|null $imageFileEn
  346.      */
  347.     public function setImageFileEn(?File $imageFileEn null): self
  348.     {
  349.         $this->imageFileEn $imageFileEn;
  350.         if (null !== $imageFileEn) {
  351.             $this->updatedAt = new \DateTimeImmutable();
  352.         }
  353.         return $this;
  354.     }
  355.     public function getImageFileEn(): ?File
  356.     {
  357.         return $this->imageFileEn;
  358.     }
  359.     public function setImageNameEn(?string $imageNameEn): self
  360.     {
  361.         $this->imageNameEn $imageNameEn;
  362.         return $this;
  363.     }
  364.     public function getImageNameEn(): ?string
  365.     {
  366.         return $this->imageNameEn;
  367.     }
  368.     public function setImageSizeEn(?int $imageSizeEn): self
  369.     {
  370.         $this->imageSizeEn $imageSizeEn;
  371.         return $this;
  372.     }
  373.     public function getImageSizeEn(): ?int
  374.     {
  375.         return $this->imageSizeEn;
  376.     }
  377.     /**
  378.      * @param File|UploadedFile|null $imageFileCa
  379.      */
  380.     public function setImageFileCa(?File $imageFileCa null): self
  381.     {
  382.         $this->imageFileCa $imageFileCa;
  383.         if (null !== $imageFileCa) {
  384.             $this->updatedAt = new \DateTimeImmutable();
  385.         }
  386.         return $this;
  387.     }
  388.     public function getImageFileCa(): ?File
  389.     {
  390.         return $this->imageFileCa;
  391.     }
  392.     public function setImageNameCa(?string $imageNameCa): self
  393.     {
  394.         $this->imageNameCa $imageNameCa;
  395.         return $this;
  396.     }
  397.     public function getImageNameCa(): ?string
  398.     {
  399.         return $this->imageNameCa;
  400.     }
  401.     public function setImageSizeCa(?int $imageSizeCa): self
  402.     {
  403.         $this->imageSizeCa $imageSizeCa;
  404.         return $this;
  405.     }
  406.     public function getImageSizeCa(): ?int
  407.     {
  408.         return $this->imageSizeCa;
  409.     }
  410.     public function getButtonName(): ?string
  411.     {
  412.         return $this->buttonName;
  413.     }
  414.     public function setButtonName(?string $buttonName): self
  415.     {
  416.         $this->buttonName $buttonName;
  417.         return $this;
  418.     }
  419.     public function getUrlEn(): ?string
  420.     {
  421.         return $this->urlEn;
  422.     }
  423.     public function setUrlEn(?string $urlEn): void
  424.     {
  425.         $this->urlEn $urlEn;
  426.     }
  427.     public function getUrlCa(): ?string
  428.     {
  429.         return $this->urlCa;
  430.     }
  431.     public function setUrlCa(?string $urlCa): void
  432.     {
  433.         $this->urlCa $urlCa;
  434.     }
  435. }