src/Entity/Result.php line 26

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Entity\Translation\ResultTranslation;
  4. use App\Repository\ResultRepository;
  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\Ignore;
  13. use Vich\UploaderBundle\Mapping\Annotation as Vich;
  14. use Doctrine\Common\Collections\ArrayCollection;
  15. use Symfony\Component\Validator\Constraints as Assert;
  16. use Symfony\Component\Serializer\Annotation\Groups;
  17. /**
  18.  * @ORM\Entity(repositoryClass=ResultRepository::class)
  19.  * @Gedmo\TranslationEntity(class="App\Entity\Translation\ResultTranslation")
  20.  * @Gedmo\SoftDeleteable(fieldName="deletedAt", timeAware=false, hardDelete=true)
  21.  * @Vich\Uploadable
  22.  */
  23. class Result implements Translatable
  24. {
  25.     use TimestampableEntity;
  26.     use SetTranslationsTrait;
  27.     public const FIELDS = [
  28.         'title'
  29.      ];
  30.     /**
  31.      * @ORM\Id
  32.      * @ORM\GeneratedValue
  33.      * @ORM\Column(type="integer")
  34.      * @Groups("result:list", "result:item")
  35.      */
  36.     private $id;
  37.     /**
  38.      * @ORM\Column(type="string", length=255, nullable=true)
  39.      * @Gedmo\Translatable
  40.      * @Groups("result:list", "result:item")
  41.      */
  42.     private $title;
  43.     /**
  44.      * @var string
  45.      * @Ignore()
  46.      */
  47.     private $titleEn null;
  48.     /**
  49.      * @var string
  50.      * @Ignore()
  51.      */
  52.     private $titleCa null;
  53.     /**
  54.     * @ORM\OneToMany(
  55.     *   targetEntity="App\Entity\Translation\ResultTranslation",
  56.     *   mappedBy="object",
  57.     *   cascade={"persist", "remove"}
  58.     * )
  59.      * @Ignore()
  60.     */
  61.     private $translations;
  62.     /**
  63.      * @Gedmo\Locale
  64.      * Used locale to override Translation listener`s locale
  65.      * this is not a mapped field of entity metadata, just a simple property
  66.      */
  67.     private $locale;
  68.     /**
  69.      * @ORM\Column(type="datetime", nullable=true)
  70.      * @var \DateTime|null
  71.      */
  72.     protected $deletedAt;
  73.     /**
  74.      * @Assert\File(
  75.      *     mimeTypes = {"image/jpeg", "image/gif", "image/png", "image/jpg"},
  76.      *     mimeTypesMessage = "Wrong file type (jpeg,gif,png,jpg)"
  77.      * )
  78.      * @Vich\UploadableField(mapping="result_image", fileNameProperty="imageName", size="imageSize")
  79.      * @var File|null
  80.      * @Ignore()
  81.      */
  82.     private $imageFile;
  83.     /**
  84.      * @ORM\Column(type="string")
  85.      *
  86.      * @var string|null
  87.      * @Groups("result:list", "result:item")
  88.      */
  89.     private $imageName;
  90.     /**
  91.      * @ORM\Column(type="integer")
  92.      *
  93.      * @var int|null
  94.      */
  95.     private $imageSize;
  96.     /**
  97.      * @Assert\File(
  98.      *     mimeTypes = {"image/jpeg", "image/gif", "image/png", "image/jpg"},
  99.      *     mimeTypesMessage = "Wrong file type (jpeg,gif,png,jpg)"
  100.      * )
  101.      * @Vich\UploadableField(mapping="result_image", fileNameProperty="imageNameEn", size="imageSizeEn")
  102.      * @var File|null
  103.      * @Ignore()
  104.      */
  105.     private $imageFileEn;
  106.     /**
  107.      * @ORM\Column(type="string", nullable=true)
  108.      *
  109.      * @var string|null
  110.      * @Groups("result:list", "result:item")
  111.      */
  112.     private $imageNameEn null;
  113.     /**
  114.      * @ORM\Column(type="integer", nullable=true)
  115.      *
  116.      * @var int|null
  117.      */
  118.     private $imageSizeEn null;
  119.     /**
  120.      * @Assert\File(
  121.      *     mimeTypes = {"image/jpeg", "image/gif", "image/png", "image/jpg"},
  122.      *     mimeTypesMessage = "Wrong file type (jpeg,gif,png,jpg)"
  123.      * )
  124.      * @Vich\UploadableField(mapping="result_image", fileNameProperty="imageNameCa", size="imageSizeCa")
  125.      * @var File|null
  126.      * @Ignore()
  127.      */
  128.     private $imageFileCa;
  129.     /**
  130.      * @ORM\Column(type="string", nullable=true)
  131.      *
  132.      * @var string|null
  133.      * @Groups("result:list", "result:item")
  134.      */
  135.     private $imageNameCa null;
  136.     /**
  137.      * @ORM\Column(type="integer", nullable=true)
  138.      *
  139.      * @var int|null
  140.      */
  141.     private $imageSizeCa null;
  142.     public function __construct()
  143.     {
  144.         $this->translations = new ArrayCollection();
  145.     }
  146.     /**
  147.      * Set or clear the deleted at timestamp.
  148.      *
  149.      * @return self
  150.      */
  151.     public function setDeletedAt(\DateTime $deletedAt null)
  152.     {
  153.         $this->deletedAt $deletedAt;
  154.         return $this;
  155.     }
  156.     /**
  157.      * Get the deleted at timestamp value. Will return null if
  158.      * the entity has not been soft deleted.
  159.      *
  160.      * @return \DateTime|null
  161.      */
  162.     public function getDeletedAt()
  163.     {
  164.         return $this->deletedAt;
  165.     }
  166.     public function setTranslatableLocale($locale)
  167.     {
  168.         $this->locale $locale;
  169.     }
  170.     public function getId(): ?int
  171.     {
  172.         return $this->id;
  173.     }
  174.     public function getTitle(): ?string
  175.     {
  176.         return $this->title;
  177.     }
  178.     public function setTitle(string $title): self
  179.     {
  180.         $this->title $title;
  181.         return $this;
  182.     }
  183.     /**
  184.      * @return mixed
  185.      */
  186.     public function getTitleEn()
  187.     {
  188.         return $this->titleEn;
  189.     }
  190.     /**
  191.      * @param string|null $titleEn
  192.      *
  193.      * @return $this
  194.      */
  195.     public function setTitleEn(?string $titleEn): self
  196.     {
  197.         $this->titleEn $titleEn;
  198.         return $this;
  199.     }
  200.     /**
  201.      * @return mixed
  202.      */
  203.     public function getTitleCa()
  204.     {
  205.         return $this->titleCa;
  206.     }
  207.     /**
  208.      * @param string|null $titleCa
  209.      *
  210.      * @return $this
  211.      */
  212.     public function setTitleCa(?string $titleCa): self
  213.     {
  214.         $this->titleCa $titleCa;
  215.         return $this;
  216.     }
  217.     /**
  218.      * @param File|UploadedFile|null $imageFile
  219.      */
  220.     public function setImageFile(?File $imageFile null): void
  221.     {
  222.         $this->imageFile $imageFile;
  223.         if (null !== $imageFile) {
  224.             $this->updatedAt = new \DateTimeImmutable();
  225.         }
  226.     }
  227.     public function getImageFile(): ?File
  228.     {
  229.         return $this->imageFile;
  230.     }
  231.     public function setImageName(?string $imageName): void
  232.     {
  233.         $this->imageName $imageName;
  234.     }
  235.     public function getImageName(): ?string
  236.     {
  237.         return $this->imageName;
  238.     }
  239.     public function setImageSize(?int $imageSize): void
  240.     {
  241.         $this->imageSize $imageSize;
  242.     }
  243.     public function getImageSize(): ?int
  244.     {
  245.         return $this->imageSize;
  246.     }
  247.     /**
  248.      * @param File|UploadedFile|null $imageFileEn
  249.      */
  250.     public function setImageFileEn(?File $imageFileEn null): void
  251.     {
  252.         $this->imageFileEn $imageFileEn;
  253.         if (null !== $imageFileEn) {
  254.             $this->updatedAt = new \DateTimeImmutable();
  255.         }
  256.     }
  257.     public function getImageFileEn(): ?File
  258.     {
  259.         return $this->imageFileEn;
  260.     }
  261.     public function setImageNameEn(?string $imageNameEn): void
  262.     {
  263.         $this->imageNameEn $imageNameEn;
  264.     }
  265.     public function getImageNameEn(): ?string
  266.     {
  267.         return $this->imageNameEn;
  268.     }
  269.     public function setImageSizeEn(?int $imageSizeEn): void
  270.     {
  271.         $this->imageSizeEn $imageSizeEn;
  272.     }
  273.     public function getImageSizeEn(): ?int
  274.     {
  275.         return $this->imageSizeEn;
  276.     }
  277.     /**
  278.      * @param File|UploadedFile|null $imageFileCa
  279.      */
  280.     public function setImageFileCa(?File $imageFileCa null): void
  281.     {
  282.         $this->imageFileCa $imageFileCa;
  283.         if (null !== $imageFileCa) {
  284.             $this->updatedAt = new \DateTimeImmutable();
  285.         }
  286.     }
  287.     public function getImageFileCa(): ?File
  288.     {
  289.         return $this->imageFileCa;
  290.     }
  291.     public function setImageNameCa(?string $imageNameCa): void
  292.     {
  293.         $this->imageNameCa $imageNameCa;
  294.     }
  295.     public function getImageNameCa(): ?string
  296.     {
  297.         return $this->imageNameCa;
  298.     }
  299.     public function setImageSizeCa(?int $imageSizeCa): void
  300.     {
  301.         $this->imageSizeCa $imageSizeCa;
  302.     }
  303.     public function getImageSizeCa(): ?int
  304.     {
  305.         return $this->imageSizeCa;
  306.     }
  307.     public function getTranslations()
  308.     {
  309.         return $this->translations;
  310.     }
  311.     public function addTranslation(ResultTranslation $t)
  312.     {
  313.         if (!$this->translations->contains($t)) {
  314.             $this->translations[] = $t;
  315.             $t->setObject($this);
  316.         }
  317.     }
  318. }