src/Entity/Experience.php line 30

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use ApiPlatform\Metadata\ApiFilter;
  4. use App\Entity\Translation\ExperienceTranslation;
  5. use App\Filter\ExperienceEnabledFilter;
  6. use App\Repository\ExperienceRepository;
  7. use DateTime;
  8. use DateTimeImmutable;
  9. use Doctrine\ORM\Mapping as ORM;
  10. use Gedmo\Mapping\Annotation as Gedmo;
  11. use Gedmo\Timestampable\Traits\TimestampableEntity;
  12. use Gedmo\Translatable\Translatable;
  13. use Symfony\Component\HttpFoundation\File\File;
  14. use Symfony\Component\HttpFoundation\File\UploadedFile;
  15. use Symfony\Component\Serializer\Annotation\Groups;
  16. use Symfony\Component\Serializer\Annotation\Ignore;
  17. use Vich\UploaderBundle\Mapping\Annotation as Vich;
  18. use Doctrine\Common\Collections\ArrayCollection;
  19. use Symfony\Component\Validator\Constraints as Assert;
  20. /**
  21.  * @ORM\Entity(repositoryClass=ExperienceRepository::class)
  22.  * @Gedmo\SoftDeleteable(fieldName="deletedAt", timeAware=false,hardDelete=false)
  23.  * @Gedmo\TranslationEntity(class="App\Entity\Translation\ExperienceTranslation")
  24.  * @Vich\Uploadable
  25.  */
  26. class Experience implements Translatable
  27. {
  28.     use TimestampableEntity;
  29.     use SetTranslationsTrait;
  30.     public const FIELDS = [
  31.         'title',
  32.         'subTitle',
  33.         'popupTitle',
  34.         'popupSubTitle',
  35.         'buttonName',
  36.         'popupButtonName',
  37.         'url'
  38.     ];
  39.     public const FIELDS_NO_FALLBACK = [
  40.         'url'
  41.     ];
  42.     /**
  43.      * @ORM\Id
  44.      * @ORM\GeneratedValue
  45.      * @ORM\Column(type="integer")
  46.      * @Groups("experience:list", "experience:item")
  47.      */
  48.     private $id;
  49.     /**
  50.      * @ORM\Column(type="string", length=255)
  51.      * @Gedmo\Translatable
  52.      * @Groups("experience:list", "experience:item")
  53.      */
  54.     private ?string $title;
  55.     /**
  56.      * @Ignore()
  57.      */
  58.     private ?string $titleEn null;
  59.     /**
  60.      * @Ignore()
  61.      */
  62.     private ?string $titleCa null;
  63.     /**
  64.      * @ORM\Column(type="string", length=255)
  65.      * @Gedmo\Translatable
  66.      * @Groups("experience:list", "experience:item")
  67.      */
  68.     private ?string $subTitle;
  69.     /**
  70.      * @Ignore()
  71.      */
  72.     private ?string $subTitleEn null;
  73.     /**
  74.      * @Ignore()
  75.      */
  76.     private ?string $subTitleCa null;
  77.     /**
  78.      * @ORM\Column(type="string", length=255)
  79.      * @Gedmo\Translatable
  80.      * @Groups("experience:list", "experience:item")
  81.      */
  82.     private ?string $popupTitle null;
  83.     /**
  84.      * @Ignore()
  85.      */
  86.     private ?string $popupTitleEn null;
  87.     /**
  88.      * @Ignore()
  89.      */
  90.     private ?string $popupTitleCa null;
  91.     /**
  92.      * @ORM\Column(type="string", length=255)
  93.      * @Gedmo\Translatable
  94.      * @Groups("experience:list", "experience:item")
  95.      */
  96.     private ?string $popupSubTitle null;
  97.     /**
  98.      * @Ignore()
  99.      */
  100.     private ?string $popupSubTitleEn null;
  101.     /**
  102.      * @Ignore()
  103.      */
  104.     private ?string $popupSubTitleCa null;
  105.     /**
  106.      * @ORM\Column(type="boolean")
  107.      * @Groups("experience:list", "experience:item")
  108.      */
  109.     private bool $enabled;
  110.     /**
  111.      * @var string
  112.      * @Groups("experience:list", "experience:item")
  113.      */
  114.     private $image;
  115.     /**
  116.      * @ORM\Column(type="string")
  117.      * @Groups("experience:list", "experience:item")
  118.      * @var string|null
  119.      *
  120.      */
  121.     private ?string $imageName null;
  122.     /**
  123.      * @ORM\Column(type="integer")
  124.      *
  125.      * @var int|null
  126.      * @Ignore()
  127.      */
  128.     private ?int $imageSize;
  129.     /**
  130.      * @ORM\Column(type="string")
  131.      * @Groups("experience:list", "experience:item")
  132.      * @var string|null
  133.      *
  134.      */
  135.     private ?string $imagePopupName null;
  136.     /**
  137.      * @ORM\Column(type="integer")
  138.      *
  139.      * @var int|null
  140.      * @Ignore()
  141.      */
  142.     private ?int $imagePopupSize;
  143.     /**
  144.      * @ORM\Column(type="string", length=255, nullable=true)
  145.      * @Groups("experience:list", "experience:item")
  146.      * @Gedmo\Translatable
  147.      */
  148.     private ?string $url;
  149.     /**
  150.      * @var string | null
  151.      * @Ignore()
  152.      */
  153.     private ?string $urlEn null;
  154.     /**
  155.      * @var string | null
  156.      * @Ignore()
  157.      */
  158.     private ?string $urlCa null;
  159.     /**
  160.      * @ORM\OneToMany(
  161.      *   targetEntity="App\Entity\Translation\ExperienceTranslation",
  162.      *   mappedBy="object",
  163.      *   cascade={"persist", "remove"}
  164.      * )
  165.      * @Ignore()
  166.      */
  167.     private $translations;
  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="experience", fileNameProperty="imageName", size="imageSize")
  174.      * @var File|null
  175.      * @Ignore()
  176.      */
  177.     private ?File $imageFile null;
  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="experience", fileNameProperty="imagePopupName", size="imagePopupSize")
  184.      * @var File|null
  185.      * @Ignore()
  186.      */
  187.     private $imagePopupFile;
  188.     /**
  189.      * @ORM\Column(type="string", nullable=true)
  190.      * @Groups("experience:list", "experience:item")
  191.      * @var string|null
  192.      * @Ignore()
  193.      *
  194.      */
  195.     private ?string $imageNameEn null;
  196.     /**
  197.      * @ORM\Column(type="integer", nullable=true)
  198.      *
  199.      * @var int|null
  200.      * @Ignore()
  201.      */
  202.     private ?int $imageSizeEn;
  203.     /**
  204.      * @Assert\File(
  205.      *     mimeTypes = {"image/jpeg", "image/gif", "image/png", "image/jpg"},
  206.      *     mimeTypesMessage = "Wrong file type (jpeg,gif,png,jpg)"
  207.      * )
  208.      * @Vich\UploadableField(mapping="experience", fileNameProperty="imageNameEn", size="imageSizeEn")
  209.      * @var File|null
  210.      * @Ignore()
  211.      */
  212.     private ?File $imageFileEn null;
  213.     /**
  214.      * @ORM\Column(type="string", nullable=true)
  215.      * @Groups("experience:list", "experience:item")
  216.      * @var string|null
  217.      * @Ignore()
  218.      *
  219.      */
  220.     private ?string $imageNameCa null;
  221.     /**
  222.      * @ORM\Column(type="integer", nullable=true)
  223.      *
  224.      * @var int|null
  225.      * @Ignore()
  226.      */
  227.     private ?int $imageSizeCa;
  228.     /**
  229.      * @Assert\File(
  230.      *     mimeTypes = {"image/jpeg", "image/gif", "image/png", "image/jpg"},
  231.      *     mimeTypesMessage = "Wrong file type (jpeg,gif,png,jpg)"
  232.      * )
  233.      * @Vich\UploadableField(mapping="experience", fileNameProperty="imageNameCa", size="imageSizeCa")
  234.      * @var File|null
  235.      * @Ignore()
  236.      */
  237.     private ?File $imageFileCa null;
  238.     /**
  239.      * @ORM\Column(type="string", length=100)
  240.      * @Gedmo\Translatable
  241.      * @Groups("experience:list", "experience:item")
  242.      */
  243.     private ?string $buttonName;
  244.     /**
  245.      * @Ignore()
  246.      */
  247.     private ?string $buttonNameEn null;
  248.     /**
  249.      * @Ignore()
  250.      */
  251.     private ?string $buttonNameCa null;
  252.     /**
  253.      * @ORM\Column(type="string", length=100)
  254.      * @Gedmo\Translatable
  255.      * @Groups("experience:list", "experience:item")
  256.      */
  257.     private ?string $popupButtonName;
  258.     /**
  259.      * @Ignore()
  260.      */
  261.     private ?string $popupButtonNameEn null;
  262.     /**
  263.      * @Ignore()
  264.      */
  265.     private ?string $popupButtonNameCa null;
  266.     /**
  267.      * @Gedmo\Locale
  268.      * Used locale to override Translation listener`s locale
  269.      * this is not a mapped field of entity metadata, just a simple property
  270.      */
  271.     private $locale;
  272.     /**
  273.      * @ORM\Column(type="datetime", nullable=true)
  274.      * @var DateTime|null
  275.      */
  276.     protected ?DateTime $deletedAt;
  277.     public function __construct()
  278.     {
  279.         $this->image $this;
  280.         $this->enabled true;
  281.         $this->translations = new ArrayCollection();
  282.     }
  283.     public function __toString(): string
  284.     {
  285.         return $this->getTitle();
  286.     }
  287.     public function getId(): ?int
  288.     {
  289.         return $this->id;
  290.     }
  291.     public function getTitle(): ?string
  292.     {
  293.         return $this->title;
  294.     }
  295.     public function setTitle(string $title): self
  296.     {
  297.         $this->title $title;
  298.         return $this;
  299.     }
  300.     /**
  301.      * @return string | null
  302.      */
  303.     public function getTitleEn(): ?string
  304.     {
  305.         return $this->titleEn;
  306.     }
  307.     /**
  308.      * @param string|null $titleEn
  309.      *
  310.      * @return $this
  311.      */
  312.     public function setTitleEn(?string $titleEn): self
  313.     {
  314.         $this->titleEn $titleEn;
  315.         return $this;
  316.     }
  317.     /**
  318.      * @return string | null
  319.      */
  320.     public function getTitleCa(): ?string
  321.     {
  322.         return $this->titleCa;
  323.     }
  324.     /**
  325.      * @param string|null $titleCa
  326.      *
  327.      * @return $this
  328.      */
  329.     public function setTitleCa(?string $titleCa): self
  330.     {
  331.         $this->titleCa $titleCa;
  332.         return $this;
  333.     }
  334.     public function getSubTitle(): ?string
  335.     {
  336.         return $this->subTitle;
  337.     }
  338.     public function setSubTitle(string $subTitle): self
  339.     {
  340.         $this->subTitle $subTitle;
  341.         return $this;
  342.     }
  343.     public function getSubTitleEn(): ?string
  344.     {
  345.         return $this->subTitleEn;
  346.     }
  347.     public function setSubTitleEn(?string $subTitleEn): self
  348.     {
  349.         $this->subTitleEn $subTitleEn;
  350.         return $this;
  351.     }
  352.     public function getSubTitleCa(): ?string
  353.     {
  354.         return $this->subTitleCa;
  355.     }
  356.     public function setSubTitleCa(?string $subTitleCa): self
  357.     {
  358.         $this->subTitleCa $subTitleCa;
  359.         return $this;
  360.     }
  361.     public function getPopupTitle(): ?string
  362.     {
  363.         return $this->popupTitle;
  364.     }
  365.     public function setPopupTitle(string $popupTitle): self
  366.     {
  367.         $this->popupTitle $popupTitle;
  368.         return $this;
  369.     }
  370.     public function getPopupTitleEn(): ?string
  371.     {
  372.         return $this->popupTitleEn;
  373.     }
  374.     public function setPopupTitleEn(?string $popupTitleEn): self
  375.     {
  376.         $this->popupTitleEn $popupTitleEn;
  377.         return $this;
  378.     }
  379.     public function getPopupTitleCa(): ?string
  380.     {
  381.         return $this->popupTitleCa;
  382.     }
  383.     public function setPopupTitleCa(?string $popupTitleCa): self
  384.     {
  385.         $this->popupTitleCa $popupTitleCa;
  386.         return $this;
  387.     }
  388.     public function getPopupSubTitle(): ?string
  389.     {
  390.         return $this->popupSubTitle;
  391.     }
  392.     public function setPopupSubTitle(string $popupSubTitle): self
  393.     {
  394.         $this->popupSubTitle $popupSubTitle;
  395.         return $this;
  396.     }
  397.     public function getPopupSubTitleEn(): ?string
  398.     {
  399.         return $this->popupSubTitleEn;
  400.     }
  401.     public function setPopupSubTitleEn(?string $popupSubTitleEn): self
  402.     {
  403.         $this->popupSubTitleEn $popupSubTitleEn;
  404.         return $this;
  405.     }
  406.     public function getPopupSubTitleCa(): ?string
  407.     {
  408.         return $this->popupSubTitleCa;
  409.     }
  410.     public function setPopupSubTitleCa(?string $popupSubTitleCa): self
  411.     {
  412.         $this->popupSubTitleCa $popupSubTitleCa;
  413.         return $this;
  414.     }
  415.     public function getEnabled(): ?bool
  416.     {
  417.         return $this->enabled;
  418.     }
  419.     public function setEnabled(bool $enabled): self
  420.     {
  421.         $this->enabled $enabled;
  422.         return $this;
  423.     }
  424.     /**
  425.      * Set or clear the deleted at timestamp.
  426.      *
  427.      * @return self
  428.      */
  429.     public function setDeletedAt(DateTime $deletedAt null)
  430.     {
  431.         $this->deletedAt $deletedAt;
  432.         return $this;
  433.     }
  434.     /**
  435.      * Get the deleted at timestamp value. Will return null if
  436.      * the entity has not been soft deleted.
  437.      *
  438.      * @return DateTime|null
  439.      */
  440.     public function getDeletedAt(): ?DateTime
  441.     {
  442.         return $this->deletedAt;
  443.     }
  444.     public function setTranslatableLocale($locale): void
  445.     {
  446.         $this->locale $locale;
  447.     }
  448.     public function getUrl(): ?string
  449.     {
  450.         return $this->url;
  451.     }
  452.     public function setUrl(?string $url): self
  453.     {
  454.         $this->url $url;
  455.         return $this;
  456.     }
  457.     /**
  458.      * @param File|null $imageFile
  459.      */
  460.     public function setImageFile(?File $imageFile null): void
  461.     {
  462.         $this->imageFile $imageFile;
  463.         if (null !== $imageFile) {
  464.             $this->updatedAt = new DateTimeImmutable();
  465.         }
  466.     }
  467.     public function getImageFile(): ?File
  468.     {
  469.         return $this->imageFile;
  470.     }
  471.     public function setImageName(?string $imageName): void
  472.     {
  473.         $this->imageName $imageName;
  474.     }
  475.     public function getImageName(): ?string
  476.     {
  477.         return $this->imageName;
  478.     }
  479.     public function setImageSize(?int $imageSize): void
  480.     {
  481.         $this->imageSize $imageSize;
  482.     }
  483.     public function getImageSize(): ?int
  484.     {
  485.         return $this->imageSize;
  486.     }
  487.     /**
  488.      * @param File|null $imagePopupFile
  489.      */
  490.     public function setImagePopupFile(?File $imagePopupFile null): void
  491.     {
  492.         $this->imagePopupFile $imagePopupFile;
  493.         if (null !== $imagePopupFile) {
  494.             $this->updatedAt = new DateTimeImmutable();
  495.         }
  496.     }
  497.     public function getImagePopupFile(): ?File
  498.     {
  499.         return $this->imagePopupFile;
  500.     }
  501.     public function setImagePopupName(?string $imagePopupName): void
  502.     {
  503.         $this->imagePopupName $imagePopupName;
  504.     }
  505.     public function getImagePopupName(): ?string
  506.     {
  507.         return $this->imagePopupName;
  508.     }
  509.     public function setImagePopupSize(?int $imagePopupSize): void
  510.     {
  511.         $this->imagePopupSize $imagePopupSize;
  512.     }
  513.     public function getImagePopupSize(): ?int
  514.     {
  515.         return $this->imagePopupSize;
  516.     }
  517.     public function getTranslations()
  518.     {
  519.         return $this->translations;
  520.     }
  521.     public function addTranslation(ExperienceTranslation $t)
  522.     {
  523.         if (!$this->translations->contains($t)) {
  524.             $this->translations[] = $t;
  525.             $t->setObject($this);
  526.         }
  527.     }
  528.     /**
  529.      * @param File|null $imageFileEn
  530.      * @return Experience
  531.      */
  532.     public function setImageFileEn(?File $imageFileEn null): self
  533.     {
  534.         $this->imageFileEn $imageFileEn;
  535.         if (null !== $imageFileEn) {
  536.             $this->updatedAt = new DateTimeImmutable();
  537.         }
  538.         return $this;
  539.     }
  540.     public function getImageFileEn(): ?File
  541.     {
  542.         return $this->imageFileEn;
  543.     }
  544.     public function setImageNameEn(?string $imageNameEn): self
  545.     {
  546.         $this->imageNameEn $imageNameEn;
  547.         return $this;
  548.     }
  549.     public function getImageNameEn(): ?string
  550.     {
  551.         return $this->imageNameEn;
  552.     }
  553.     public function setImageSizeEn(?int $imageSizeEn): self
  554.     {
  555.         $this->imageSizeEn $imageSizeEn;
  556.         return $this;
  557.     }
  558.     public function getImageSizeEn(): ?int
  559.     {
  560.         return $this->imageSizeEn;
  561.     }
  562.     /**
  563.      * @param File|null $imageFileCa
  564.      * @return Experience
  565.      */
  566.     public function setImageFileCa(?File $imageFileCa null): self
  567.     {
  568.         $this->imageFileCa $imageFileCa;
  569.         if (null !== $imageFileCa) {
  570.             $this->updatedAt = new DateTimeImmutable();
  571.         }
  572.         return $this;
  573.     }
  574.     public function getImageFileCa(): ?File
  575.     {
  576.         return $this->imageFileCa;
  577.     }
  578.     public function setImageNameCa(?string $imageNameCa): self
  579.     {
  580.         $this->imageNameCa $imageNameCa;
  581.         return $this;
  582.     }
  583.     public function getImageNameCa(): ?string
  584.     {
  585.         return $this->imageNameCa;
  586.     }
  587.     public function setImageSizeCa(?int $imageSizeCa): self
  588.     {
  589.         $this->imageSizeCa $imageSizeCa;
  590.         return $this;
  591.     }
  592.     public function getImageSizeCa(): ?int
  593.     {
  594.         return $this->imageSizeCa;
  595.     }
  596.     public function getButtonName(): ?string
  597.     {
  598.         return $this->buttonName;
  599.     }
  600.     public function setButtonName(?string $buttonName): self
  601.     {
  602.         $this->buttonName $buttonName;
  603.         return $this;
  604.     }
  605.     public function getButtonNameEn(): ?string
  606.     {
  607.         return $this->buttonNameEn;
  608.     }
  609.     public function setButtonNameEn(?string $buttonNameEn): self
  610.     {
  611.         $this->buttonNameEn $buttonNameEn;
  612.         return $this;
  613.     }
  614.     public function getButtonNameCa(): ?string
  615.     {
  616.         return $this->buttonNameCa;
  617.     }
  618.     public function setButtonNameCa(?string $buttonNameCa): self
  619.     {
  620.         $this->buttonNameCa $buttonNameCa;
  621.         return $this;
  622.     }
  623.     public function getPopupButtonName(): ?string
  624.     {
  625.         return $this->popupButtonName;
  626.     }
  627.     public function setPopupButtonName(?string $popupButtonName): self
  628.     {
  629.         $this->popupButtonName $popupButtonName;
  630.         return $this;
  631.     }
  632.     public function getPopupButtonNameEn(): ?string
  633.     {
  634.         return $this->popupButtonNameEn;
  635.     }
  636.     public function setPopupButtonNameEn(?string $popupButtonNameEn): self
  637.     {
  638.         $this->popupButtonNameEn $popupButtonNameEn;
  639.         return $this;
  640.     }
  641.     public function getPopupButtonNameCa(): ?string
  642.     {
  643.         return $this->popupButtonNameCa;
  644.     }
  645.     public function setPopupButtonNameCa(?string $popupButtonNameCa): self
  646.     {
  647.         $this->popupButtonNameCa $popupButtonNameCa;
  648.         return $this;
  649.     }
  650.     /**
  651.      * @return string | null
  652.      */
  653.     public function getUrlEn(): ?string
  654.     {
  655.         return $this->urlEn;
  656.     }
  657.     /**
  658.      * @param string | null $urlEn
  659.      */
  660.     public function setUrlEn(?string $urlEn): void
  661.     {
  662.         $this->urlEn $urlEn;
  663.     }
  664.     /**
  665.      * @return string | null
  666.      */
  667.     public function getUrlCa(): ?string
  668.     {
  669.         return $this->urlCa;
  670.     }
  671.     /**
  672.      * @param string | null $urlCa
  673.      */
  674.     public function setUrlCa(?string $urlCa): void
  675.     {
  676.         $this->urlCa $urlCa;
  677.     }
  678. }