src/Entity/PaperSize.php line 13

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