src/Entity/BannerSection.php line 25

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