src/Entity/Gos/Uniqskills/Voucher.php line 18

Open in your IDE?
  1. <?php
  2. namespace App\Entity\Gos\Uniqskills;
  3. use App\Entity\Gos\Language;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. use Symfony\Component\Validator\Constraints as Assert;
  8. use Symfony\Component\HttpFoundation\File\File;
  9. use Vich\UploaderBundle\Mapping\Annotation as Vich;
  10. /**
  11.  * @ORM\Entity(repositoryClass="App\Repository\Gos\Uniqskills\VoucherRepository")
  12.  * @Vich\Uploadable()
  13.  * @ORM\HasLifecycleCallbacks()
  14.  */
  15. class Voucher
  16. {
  17.     /**
  18.      * @ORM\Id()
  19.      * @ORM\GeneratedValue()
  20.      * @ORM\Column(type="integer")
  21.      */
  22.     private $id;
  23.     /**
  24.      * @ORM\Column(type="string", length=255)
  25.      */
  26.     private $name;
  27.     /**
  28.      * @ORM\Column(type="boolean", nullable=true)
  29.      */
  30.     private $pageOrientationLandscape;
  31.     /**
  32.      * @ORM\ManyToMany(targetEntity="App\Entity\Gos\Language", inversedBy="vouchers")
  33.      * @ORM\JoinTable(name="voucher_language_defaults")
  34.      */
  35.     private $isDefaultForLanguage;
  36.     /**
  37.      * @ORM\OneToOne(targetEntity="App\Entity\Gos\Uniqskills\Course", inversedBy="voucher")
  38.      * @ORM\JoinColumn(referencedColumnName="id", onDelete="cascade")
  39.      */
  40.     private $course;
  41.     /**
  42.      * @Assert\File(
  43.      *     maxSize="5M",
  44.      *     mimeTypes={"application/pdf", "application/x-pdf"}
  45.      * )
  46.      *
  47.      * @Vich\UploadableField(mapping="product_image", fileNameProperty="pdfName")
  48.      */
  49.     private $file;
  50.     /**
  51.      * @ORM\Column(type="string", length=255, nullable=true)
  52.      */
  53.     private $pdfName;
  54.     /**
  55.      * @ORM\OneToMany(targetEntity="App\Entity\Gos\Uniqskills\VoucherElement", mappedBy="voucher")
  56.      */
  57.     private $voucherElements;
  58.     /**
  59.      * @ORM\Column(type="datetime")
  60.      */
  61.     private $createdAt;
  62.     /**
  63.      * @ORM\Column(type="datetime", nullable=true)
  64.      */
  65.     private $updatedAt;
  66.     public function __construct()
  67.     {
  68.         $this->isDefaultForLanguage = new ArrayCollection();
  69.         $this->voucherElements = new ArrayCollection();
  70.     }
  71.     /** @ORM\PrePersist() */
  72.     public function prePersist()
  73.     {
  74.         $this->createdAt = new \DateTime();
  75.     }
  76.     /** @ORM\PreUpdate() */
  77.     public function preUpdate()
  78.     {
  79.         $this->updatedAt = new \DateTime();
  80.     }
  81.     public function __toString()
  82.     {
  83.         return (string) $this->name;
  84.     }
  85.     public function setFile(File $voucherTemplate null): self
  86.     {
  87.         $this->file $voucherTemplate;
  88.         if ($voucherTemplate)
  89.         {
  90.             $this->updatedAt = new \DateTimeImmutable();
  91.         }
  92.         return $this;
  93.     }
  94.     public function getFile(): ?File
  95.     {
  96.         return $this->file;
  97.     }
  98.     public function getId(): ?int
  99.     {
  100.         return $this->id;
  101.     }
  102.     public function getName(): ?string
  103.     {
  104.         return $this->name;
  105.     }
  106.     public function setName(string $name): self
  107.     {
  108.         $this->name $name;
  109.         return $this;
  110.     }
  111.     public function getPageOrientationLandscape(): ?bool
  112.     {
  113.         return $this->pageOrientationLandscape;
  114.     }
  115.     public function setPageOrientationLandscape(?bool $pageOrientationLandscape): self
  116.     {
  117.         $this->pageOrientationLandscape $pageOrientationLandscape;
  118.         return $this;
  119.     }
  120.     public function getPdfName(): ?string
  121.     {
  122.         return $this->pdfName;
  123.     }
  124.     public function setPdfName(?string $pdfName): self
  125.     {
  126.         $this->pdfName $pdfName;
  127.         return $this;
  128.     }
  129.     public function getCreatedAt(): ?\DateTimeInterface
  130.     {
  131.         return $this->createdAt;
  132.     }
  133.     public function setCreatedAt(\DateTimeInterface $createdAt): self
  134.     {
  135.         $this->createdAt $createdAt;
  136.         return $this;
  137.     }
  138.     public function getUpdatedAt(): ?\DateTimeInterface
  139.     {
  140.         return $this->updatedAt;
  141.     }
  142.     public function setUpdatedAt(?\DateTimeInterface $updatedAt): self
  143.     {
  144.         $this->updatedAt $updatedAt;
  145.         return $this;
  146.     }
  147.     /**
  148.      * @return Collection|Language[]
  149.      */
  150.     public function getIsDefaultForLanguage(): Collection
  151.     {
  152.         return $this->isDefaultForLanguage;
  153.     }
  154.     public function addIsDefaultForLanguage(Language $isDefaultForLanguage): self
  155.     {
  156.         if (!$this->isDefaultForLanguage->contains($isDefaultForLanguage)) {
  157.             $this->isDefaultForLanguage[] = $isDefaultForLanguage;
  158.         }
  159.         return $this;
  160.     }
  161.     public function removeIsDefaultForLanguage(Language $isDefaultForLanguage): self
  162.     {
  163.         if ($this->isDefaultForLanguage->contains($isDefaultForLanguage)) {
  164.             $this->isDefaultForLanguage->removeElement($isDefaultForLanguage);
  165.         }
  166.         return $this;
  167.     }
  168.     public function getCourse(): ?Course
  169.     {
  170.         return $this->course;
  171.     }
  172.     public function setCourse(?Course $course): self
  173.     {
  174.         $this->course $course;
  175.         return $this;
  176.     }
  177.     /**
  178.      * @return Collection|VoucherElement[]
  179.      */
  180.     public function getVoucherElements(): Collection
  181.     {
  182.         return $this->voucherElements;
  183.     }
  184.     public function addVoucherElement(VoucherElement $voucherElement): self
  185.     {
  186.         if (!$this->voucherElements->contains($voucherElement)) {
  187.             $this->voucherElements[] = $voucherElement;
  188.             $voucherElement->setVoucher($this);
  189.         }
  190.         return $this;
  191.     }
  192.     public function removeVoucherElement(VoucherElement $voucherElement): self
  193.     {
  194.         if ($this->voucherElements->contains($voucherElement)) {
  195.             $this->voucherElements->removeElement($voucherElement);
  196.             // set the owning side to null (unless already changed)
  197.             if ($voucherElement->getVoucher() === $this) {
  198.                 $voucherElement->setVoucher(null);
  199.             }
  200.         }
  201.         return $this;
  202.     }
  203. }