<?php
namespace App\Entity;
use App\Repository\SelectionWiperRepository;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Serializer\Annotation\MaxDepth;
use Symfony\Component\Serializer\Annotation as Serializer;
use Symfony\Component\Serializer\Annotation\SerializedName;
use App\Annotation\DashboardAnnotation as Dashboard;
/**
* @ORM\Entity(repositoryClass=SelectionWiperRepository::class)
* @Dashboard(generation=true, name="Данные подбора щеток")
*/
class SelectionWiper
{
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
* @Serializer\Groups({"collection", "selection/data"})
*/
private $id;
/**
* @ORM\ManyToOne(targetEntity=Modification::class, inversedBy="selectionWipers")
* @Serializer\Groups({"collection"})
*/
private $modification;
/**
* @ORM\Column(type="string", length=255, nullable=true)
* @Serializer\Groups({"collection", "selection/data"})
*/
private $size1;
/**
* @ORM\Column(type="string", length=255, nullable=true)
* @Serializer\Groups({"collection", "selection/data"})
*/
private $size2;
/**
* @ORM\ManyToOne(targetEntity=Fastener::class, inversedBy="selectionWipers")
* @ORM\JoinColumn(nullable=true)
* @Serializer\Groups({"collection", "selection/data"})
*/
private $fastener;
/**
* @ORM\ManyToOne(targetEntity=ProductArticle::class, inversedBy="selectionWipers")
* @Serializer\Groups({"collection"})
*/
private $productArticle;
public function getId(): ?int
{
return $this->id;
}
public function getModification(): ?Modification
{
return $this->modification;
}
public function setModification(?Modification $modification): self
{
$this->modification = $modification;
return $this;
}
public function getFastener(): ?Fastener
{
return $this->fastener;
}
public function setFastener(?Fastener $fastener): self
{
$this->fastener = $fastener;
return $this;
}
public function getSize1(): ?string
{
return $this->size1;
}
public function setSize1(?string $size1): self
{
$this->size1 = $size1;
return $this;
}
public function getSize2(): ?string
{
return $this->size2;
}
public function setSize2(?string $size2): self
{
$this->size2 = $size2;
return $this;
}
public function getProductArticle(): ?ProductArticle
{
return $this->productArticle;
}
public function setProductArticle(?ProductArticle $productArticle): self
{
$this->productArticle = $productArticle;
return $this;
}
/**
* @Serializer\Groups({"selection/applicable"})
* @SerializedName("title")
*/
public function getApplicableTitle(): string
{
$title = '';
if ($modification = $this->getModification()) {
$title = $modification->getModel()->getMark()->getTitle() . ' ' . $modification->getModel()->getTitle() . ' [' . $modification->getParams() .']';
}
return $title;
}
/**
* @Serializer\Groups({"selection/applicable"})
*/
public function getRef(): array
{
if ($modification = $this->getModification()) {
return [
//'modification' => $modification->getId(),
'mark' => $modification->getModel()->getMark()->getId(),
'model' => $modification->getModel()->getId(),
'body' => $modification->getBody(),
'years' => ($modification->getYearFrom() ?? '') . '|' . ($modification->getYearTo() ?? '')
];
}
return [];
}
}