src/Entity/PaperSize.php line 14

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\PaperSizeRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. use Gedmo\Timestampable\Traits\TimestampableEntity;
  8. use Symfony\Component\Serializer\Annotation\Groups;
  9. /**
  10.  * @ORM\Entity(repositoryClass=PaperSizeRepository::class)
  11.  */
  12. class PaperSize
  13. {
  14.     use TimestampableEntity;
  15.     /**
  16.      * @ORM\Id
  17.      * @ORM\GeneratedValue
  18.      * @ORM\Column(type="integer")
  19.      * @Groups({"machine"})
  20.      */
  21.     private $id;
  22.     /**
  23.      * @ORM\Column(type="string", length=255)
  24.      * @Groups({"machine"})
  25.      */
  26.     private $name;
  27.     /**
  28.      * @ORM\Column(type="string", length=255)
  29.      * @Groups({"machine"})
  30.      */
  31.     private $code;
  32.     /**
  33.      * @ORM\Column(type="text", nullable=true)
  34.      * @Groups({"machine"})
  35.      */
  36.     private $description;
  37.     /**
  38.      * @ORM\Column(type="integer")
  39.      * @Groups({"machine"})
  40.      */
  41.     private $width;
  42.     /**
  43.      * @ORM\Column(type="integer")
  44.      * @Groups({"machine"})
  45.      */
  46.     private $height;
  47.     /**
  48.      * @ORM\ManyToMany(targetEntity=Machine::class, inversedBy="paperSizes", cascade={"persist"})
  49.      */
  50.     private $machines;
  51.     /**
  52.      * @ORM\OneToMany(targetEntity=MachinePaperSizeMatrix::class, mappedBy="paperSize")
  53.      */
  54.     private $machinePaperSizeMatrices;
  55.     public function __construct()
  56.     {
  57.         $this->machines = new ArrayCollection();
  58.         $this->machinePaperSizeMatrices = new ArrayCollection();
  59.     }
  60.     public function getId(): ?int
  61.     {
  62.         return $this->id;
  63.     }
  64.     public function getName(): ?string
  65.     {
  66.         return $this->name;
  67.     }
  68.     public function setName(string $name): self
  69.     {
  70.         $this->name $name;
  71.         return $this;
  72.     }
  73.     public function getCode(): ?string
  74.     {
  75.         return $this->code;
  76.     }
  77.     public function setCode(string $code): self
  78.     {
  79.         $this->code $code;
  80.         return $this;
  81.     }
  82.     public function getDescription(): ?string
  83.     {
  84.         return $this->description;
  85.     }
  86.     public function setDescription(?string $description): self
  87.     {
  88.         $this->description $description;
  89.         return $this;
  90.     }
  91.     public function getWidth(): ?int
  92.     {
  93.         return $this->width;
  94.     }
  95.     public function setWidth(int $width): self
  96.     {
  97.         $this->width $width;
  98.         return $this;
  99.     }
  100.     public function getHeight(): ?int
  101.     {
  102.         return $this->height;
  103.     }
  104.     public function setHeight(int $height): self
  105.     {
  106.         $this->height $height;
  107.         return $this;
  108.     }
  109.     /**
  110.      * @return Collection<int, Machine>
  111.      */
  112.     public function getMachines(): Collection
  113.     {
  114.         return $this->machines;
  115.     }
  116.     public function addMachine(Machine $machine): self
  117.     {
  118.         if (!$this->machines->contains($machine)) {
  119.             $this->machines[] = $machine;
  120.         }
  121.         return $this;
  122.     }
  123.     public function removeMachine(Machine $machine): self
  124.     {
  125.         $this->machines->removeElement($machine);
  126.         return $this;
  127.     }
  128.     /**
  129.      * @return Collection<int, MachinePaperSizeMatrix>
  130.      */
  131.     public function getMachinePaperSizeMatrices(): Collection
  132.     {
  133.         return $this->machinePaperSizeMatrices;
  134.     }
  135.     public function addMachinePaperSizeMatrix(MachinePaperSizeMatrix $machinePaperSizeMatrix): self
  136.     {
  137.         if (!$this->machinePaperSizeMatrices->contains($machinePaperSizeMatrix)) {
  138.             $this->machinePaperSizeMatrices[] = $machinePaperSizeMatrix;
  139.             $machinePaperSizeMatrix->setPaperSize($this);
  140.         }
  141.         return $this;
  142.     }
  143.     public function removeMachinePaperSizeMatrix(MachinePaperSizeMatrix $machinePaperSizeMatrix): self
  144.     {
  145.         if ($this->machinePaperSizeMatrices->removeElement($machinePaperSizeMatrix)) {
  146.             // set the owning side to null (unless already changed)
  147.             if ($machinePaperSizeMatrix->getPaperSize() === $this) {
  148.                 $machinePaperSizeMatrix->setPaperSize(null);
  149.             }
  150.         }
  151.         return $this;
  152.     }
  153.     public function getCalculatorDisplayName():string
  154.     {
  155.         return '['.$this->code.']['.$this->width.'x'.$this->height.']['.$this->name.']';
  156.     }
  157.     public function __toString() {
  158.         return $this->name;
  159.     }
  160. }