src/Entity/WinWOP/LicenseRequest.php line 21

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\Machine;
  7. use Doctrine\Common\Collections\Collection;
  8. use Doctrine\ORM\Mapping as ORM;
  9. use Symfony\Component\HttpFoundation\File\File;
  10. use Vich\UploaderBundle\Mapping\Annotation as Vich;
  11. use Symfony\Component\Validator\Constraints as Assert;
  12. /**
  13.  * @ORM\Entity
  14.  * @ORM\HasLifecycleCallbacks()
  15.  * @ORM\Table(name="win_wop_license_requests")
  16.  * @Vich\Uploadable
  17.  */
  18. class LicenseRequest
  19. {
  20.     /**
  21.      * @ORM\Id
  22.      * @ORM\Column(type="integer")
  23.      * @ORM\GeneratedValue(strategy="AUTO")
  24.      */
  25.     protected $id;
  26.     /**
  27.      * @ORM\OneToOne(targetEntity="App\Entity\Machine", inversedBy="license_request", cascade={"persist"})
  28.      */
  29.     private $machine;
  30.     /**
  31.      * @ORM\Column(name="manufacturer_name", type="string", length=190)
  32.      *
  33.      * @var string
  34.      */
  35.     private $manufacturerName;
  36.     /**
  37.      * @ORM\Column(name="machine_name", type="string", length=190)
  38.      *
  39.      * @var string
  40.      */
  41.     private $name;
  42.     /**
  43.      * @ORM\Column(name="machine_serial", type="string", length=190)
  44.      *
  45.      * @var string
  46.      */
  47.     private $serial;
  48.     /**
  49.      * @ORM\Column(name="machine_control", type="string", length=190)
  50.      *
  51.      * @var string
  52.      */
  53.     private $control false;
  54.     /**
  55.      * @ORM\Column(name="license_number", type="string", length=190)
  56.      *
  57.      * @var string
  58.      */
  59.     private $licenseNumber;
  60.     /**
  61.      * @var \DateTime
  62.      *
  63.      * @ORM\Column(name="created", type="datetime", nullable=false)
  64.      */
  65.     private $created;
  66.     /**
  67.      * NOTE: This is not a mapped field of entity metadata, just a simple property.
  68.      *
  69.      * @Vich\UploadableField(mapping="license_request_file", fileNameProperty="localPath")
  70.      *
  71.      * @var File
  72.      */
  73.     private $file;
  74.     /**
  75.      * @ORM\Column(name="local_file", type="string", length=255)
  76.      *
  77.      * @var string
  78.      */
  79.     private $localPath;
  80.     /**
  81.      * Constructor
  82.      */
  83.     public function __construct()
  84.     {
  85.         $this->created = new \DateTime();
  86.         $this->modules = new \Doctrine\Common\Collections\ArrayCollection();
  87.     }
  88.     public function getId()
  89.     {
  90.         return $this->id;
  91.     }
  92.     public function setManufacturerName($manufacturerName)
  93.     {
  94.         $this->manufacturerName $manufacturerName;
  95.         return $this;
  96.     }
  97.     public function getManufacturerName()
  98.     {
  99.         return $this->manufacturerName;
  100.     }
  101.     public function setName($name)
  102.     {
  103.         $this->name $name;
  104.         return $this;
  105.     }
  106.     public function getName()
  107.     {
  108.         return $this->name;
  109.     }
  110.     public function setSerial($serial)
  111.     {
  112.         $this->serial $serial;
  113.         return $this;
  114.     }
  115.     public function getSerial()
  116.     {
  117.         return $this->serial;
  118.     }
  119.     public function setControl($control)
  120.     {
  121.         $this->control $control;
  122.         return $this;
  123.     }
  124.     public function getControl()
  125.     {
  126.         return $this->control;
  127.     }
  128.     public function setLicenseNumber($licenseNumber)
  129.     {
  130.         $this->licenseNumber $licenseNumber;
  131.         return $this;
  132.     }
  133.     public function getLicenseNumber()
  134.     {
  135.         return $this->licenseNumber;
  136.     }
  137.     /**
  138.      * If manually uploading a file (i.e. not using Symfony Form) ensure an instance
  139.      * of 'UploadedFile' is injected into this setter to trigger the update. If this
  140.      * bundle's configuration parameter 'inject_on_load' is set to 'true' this setter
  141.      * must be able to accept an instance of 'File' as the bundle will inject one here
  142.      * during Doctrine hydration.
  143.      *
  144.      * @param File|\Symfony\Component\HttpFoundation\File\UploadedFile $file
  145.      * @throws \Exception
  146.      */
  147.     public function setFile(?File $file null): void
  148.     {
  149.         $this->file $file;
  150.         if (null !== $file) {
  151.             // It is required that at least one field changes if you are using doctrine
  152.             // otherwise the event listeners won't be called and the file is lost
  153.             $this->created = new \DateTimeImmutable();
  154.         }
  155.     }
  156.     public function getFile(): ?File
  157.     {
  158.         return $this->file;
  159.     }
  160.     public function setCreated($created)
  161.     {
  162.         $this->created $created;
  163.         return $this;
  164.     }
  165.     public function getCreated()
  166.     {
  167.         return $this->created;
  168.     }
  169.     public function setLocalPath($localPath)
  170.     {
  171.         $this->localPath $localPath;
  172.         return $this;
  173.     }
  174.     public function getLocalPath()
  175.     {
  176.         return $this->localPath;
  177.     }
  178.     public function setMachine(Machine $machine null)
  179.     {
  180.         $this->machine $machine;
  181.         return $this;
  182.     }
  183.     public function getMachine() : ?Machine
  184.     {
  185.         return $this->machine;
  186.     }
  187.     public function __toString()
  188.     {
  189.         $date $this->getCreated();
  190.         if ($date) {
  191.             return $date->format('d.m.Y H:i');
  192.         }
  193.         return '';
  194.     }
  195. }