src/Entity/WinWOP/Update.php line 23

Open in your IDE?
  1. <?php
  2. /**
  3.  * Copyright (c) 2019, MND Next GmbH - www.mndnext.de
  4.  */
  5. namespace App\Entity\WinWOP;
  6. use App\Entity\WinWOP\File\Documentation;
  7. use App\Entity\WinWOP\File\InstallDoc;
  8. use Doctrine\Common\Collections\Collection;
  9. use Doctrine\ORM\Mapping as ORM;
  10. use Symfony\Component\HttpFoundation\File\File;
  11. use Vich\UploaderBundle\Mapping\Annotation as Vich;
  12. use Symfony\Component\Validator\Constraints as Assert;
  13. use Doctrine\Common\Collections\ArrayCollection;
  14. /**
  15.  * @ORM\Entity
  16.  * @ORM\HasLifecycleCallbacks()
  17.  * @ORM\Table(name="win_wop_updates")
  18.  * @Vich\Uploadable
  19.  */
  20. class Update
  21. {
  22.     /**
  23.      * @var string
  24.      * @ORM\Id
  25.      * @ORM\Column(type="string", length=190)
  26.      */
  27.     protected $version;
  28.     /**
  29.      * @var \DateTime
  30.      * @ORM\Column(name="release_date", type="datetime", nullable=false)
  31.      */
  32.     private $release;
  33.     /**
  34.      * NOTE: This is not a mapped field of entity metadata, just a simple property.
  35.      *
  36.      * @Vich\UploadableField(mapping="update_file", fileNameProperty="path")
  37.      *
  38.      * @var File
  39.      */
  40.     private $file;
  41.     /**
  42.      * @ORM\Column(name="file", type="string", length=255)
  43.      *
  44.      * @var string
  45.      */
  46.     private $path;
  47.     /**
  48.      * @ORM\OneToMany(targetEntity="App\Entity\WinWOP\File\Documentation", mappedBy="winwop", cascade={"persist"})
  49.      * @ORM\OrderBy({"created" = "DESC"})
  50.      */
  51.     private $docuFiles;
  52.     /**
  53.      * @ORM\OneToMany(targetEntity="App\Entity\WinWOP\File\InstallDoc", mappedBy="winwop", cascade={"persist"})
  54.      * @ORM\OrderBy({"created" = "DESC"})
  55.      */
  56.     private $installDocFiles;
  57.     /**
  58.      * @var string
  59.      * @ORM\Column(name="compatibility", type="string", length=255, nullable=true)
  60.      */
  61.     private $compatibility;
  62.     /**
  63.      * @ORM\OneToMany(targetEntity="License", mappedBy="version", cascade={"persist", "refresh"})
  64.      */
  65.     private $licenses;
  66.     /**
  67.      * @ORM\Column(name="public", type="boolean", nullable=false)
  68.      */
  69.     private $public;
  70.     /**
  71.      * @ORM\Column(name="notified", type="boolean", nullable=false)
  72.      */
  73.     private $notified;
  74.     /**
  75.      * Constructor
  76.      */
  77.     public function __construct()
  78.     {
  79.         $this->licenses = new ArrayCollection();
  80.         $this->docuFiles = new ArrayCollection();
  81.         $this->installDocFiles = new ArrayCollection();
  82.         $this->release = new \DateTime();
  83.         $this->public false;
  84.         $this->notified false;
  85.     }
  86.     public function getVersion(): ?string
  87.     {
  88.         return $this->version;
  89.     }
  90.     public function setVersion($version)
  91.     {
  92.         $this->version $version;
  93.         return $this;
  94.     }
  95.     public function getRelease(): ?\DateTime
  96.     {
  97.         return $this->release;
  98.     }
  99.     public function setRelease($release)
  100.     {
  101.         $this->release $release;
  102.         return $this;
  103.     }
  104.     /**
  105.      * If manually uploading a file (i.e. not using Symfony Form) ensure an instance
  106.      * of 'UploadedFile' is injected into this setter to trigger the update. If this
  107.      * bundle's configuration parameter 'inject_on_load' is set to 'true' this setter
  108.      * must be able to accept an instance of 'File' as the bundle will inject one here
  109.      * during Doctrine hydration.
  110.      *
  111.      * @param File|\Symfony\Component\HttpFoundation\File\UploadedFile $file
  112.      * @throws \Exception
  113.      */
  114.     public function setFile(?File $file null): void
  115.     {
  116.         $this->file $file;
  117.         if (null !== $file) {
  118.             // It is required that at least one field changes if you are using doctrine
  119.             // otherwise the event listeners won't be called and the file is lost
  120.             //$this->release = new \DateTimeImmutable();
  121.         }
  122.     }
  123.     public function getFile(): ?File
  124.     {
  125.         return $this->file;
  126.     }
  127.     public function addDocuFile(?Documentation $file null): void
  128.     {
  129.         $this->docuFiles->add($file);
  130.     }
  131.     public function removeDocuFile(?Documentation $file null): void
  132.     {
  133.         $this->docuFiles->removeElement($file);
  134.     }
  135.     public function getDocuFiles(): Collection
  136.     {
  137.         return $this->docuFiles;
  138.     }
  139.     public function addInstallDocFile(?InstallDoc $file null): void
  140.     {
  141.         $this->installDocFiles->add($file);
  142.     }
  143.     public function removeInstallDocFile(?InstallDoc $file null): void
  144.     {
  145.         $this->installDocFiles->removeElement($file);
  146.     }
  147.     /**
  148.      * @return Collection|InstallDoc[]
  149.      */
  150.     public function getInstallDocFiles(): Collection
  151.     {
  152.         return $this->installDocFiles;
  153.     }
  154.     public function setPath($path)
  155.     {
  156.         $this->path $path;
  157.         return $this;
  158.     }
  159.     public function getPath(): ?string
  160.     {
  161.         return $this->path;
  162.     }
  163.     public function setCompatibility($compatibility)
  164.     {
  165.         $this->compatibility $compatibility;
  166.         return $this;
  167.     }
  168.     public function getCompatibility()
  169.     {
  170.         return $this->compatibility;
  171.     }
  172.     public function setPublic($public)
  173.     {
  174.         $this->public $public?true:false;
  175.         return $this;
  176.     }
  177.     public function isPublic()
  178.     {
  179.         return $this->public;
  180.     }
  181.     public function setNotified($notified)
  182.     {
  183.         $this->notified $notified?true:false;
  184.         return $this;
  185.     }
  186.     public function isNotified()
  187.     {
  188.         return $this->notified;
  189.     }
  190.     /**
  191.      * @return Collection|License[]
  192.      */
  193.     public function getLicenses() : Collection
  194.     {
  195.         return $this->licenses;
  196.     }
  197.     public function __toString()
  198.     {
  199.         return $this->getVersion();
  200.     }
  201. }