src/Entity/Sponsor.php line 26

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