src/Entity/BannerSponsorSecondary.php line 26

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