<?php
namespace App\Entity;
use App\Repository\PaperSizeRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Gedmo\Timestampable\Traits\TimestampableEntity;
use Symfony\Component\Serializer\Annotation\Groups;
/**
* @ORM\Entity(repositoryClass=PaperSizeRepository::class)
*/
class PaperSize
{
use TimestampableEntity;
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
* @Groups({"machine"})
*/
private $id;
/**
* @ORM\Column(type="string", length=255)
* @Groups({"machine"})
*/
private $name;
/**
* @ORM\Column(type="string", length=255)
* @Groups({"machine"})
*/
private $code;
/**
* @ORM\Column(type="text", nullable=true)
* @Groups({"machine"})
*/
private $description;
/**
* @ORM\Column(type="integer")
* @Groups({"machine"})
*/
private $width;
/**
* @ORM\Column(type="integer")
* @Groups({"machine"})
*/
private $height;
/**
* @ORM\ManyToMany(targetEntity=Machine::class, inversedBy="paperSizes", cascade={"persist"})
*/
private $machines;
/**
* @ORM\OneToMany(targetEntity=MachinePaperSizeMatrix::class, mappedBy="paperSize")
*/
private $machinePaperSizeMatrices;
public function __construct()
{
$this->machines = new ArrayCollection();
$this->machinePaperSizeMatrices = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getName(): ?string
{
return $this->name;
}
public function setName(string $name): self
{
$this->name = $name;
return $this;
}
public function getCode(): ?string
{
return $this->code;
}
public function setCode(string $code): self
{
$this->code = $code;
return $this;
}
public function getDescription(): ?string
{
return $this->description;
}
public function setDescription(?string $description): self
{
$this->description = $description;
return $this;
}
public function getWidth(): ?int
{
return $this->width;
}
public function setWidth(int $width): self
{
$this->width = $width;
return $this;
}
public function getHeight(): ?int
{
return $this->height;
}
public function setHeight(int $height): self
{
$this->height = $height;
return $this;
}
/**
* @return Collection<int, Machine>
*/
public function getMachines(): Collection
{
return $this->machines;
}
public function addMachine(Machine $machine): self
{
if (!$this->machines->contains($machine)) {
$this->machines[] = $machine;
}
return $this;
}
public function removeMachine(Machine $machine): self
{
$this->machines->removeElement($machine);
return $this;
}
/**
* @return Collection<int, MachinePaperSizeMatrix>
*/
public function getMachinePaperSizeMatrices(): Collection
{
return $this->machinePaperSizeMatrices;
}
public function addMachinePaperSizeMatrix(MachinePaperSizeMatrix $machinePaperSizeMatrix): self
{
if (!$this->machinePaperSizeMatrices->contains($machinePaperSizeMatrix)) {
$this->machinePaperSizeMatrices[] = $machinePaperSizeMatrix;
$machinePaperSizeMatrix->setPaperSize($this);
}
return $this;
}
public function removeMachinePaperSizeMatrix(MachinePaperSizeMatrix $machinePaperSizeMatrix): self
{
if ($this->machinePaperSizeMatrices->removeElement($machinePaperSizeMatrix)) {
// set the owning side to null (unless already changed)
if ($machinePaperSizeMatrix->getPaperSize() === $this) {
$machinePaperSizeMatrix->setPaperSize(null);
}
}
return $this;
}
public function getCalculatorDisplayName():string
{
return '['.$this->code.']['.$this->width.'x'.$this->height.']['.$this->name.']';
}
public function __toString() {
return $this->name;
}
}