src/Entity/SelectionWiper.php line 16

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\SelectionWiperRepository;
  4. use Doctrine\ORM\Mapping as ORM;
  5. use Symfony\Component\Serializer\Annotation\MaxDepth;
  6. use Symfony\Component\Serializer\Annotation as Serializer;
  7. use Symfony\Component\Serializer\Annotation\SerializedName;
  8. use App\Annotation\DashboardAnnotation as Dashboard;
  9. /**
  10.  * @ORM\Entity(repositoryClass=SelectionWiperRepository::class)
  11.  * @Dashboard(generation=true, name="Данные подбора щеток")
  12.  */
  13. class SelectionWiper
  14. {
  15.     /**
  16.      * @ORM\Id
  17.      * @ORM\GeneratedValue
  18.      * @ORM\Column(type="integer")
  19.      * @Serializer\Groups({"collection", "selection/data"}) 
  20.      */
  21.     private $id;
  22.     /**
  23.      * @ORM\ManyToOne(targetEntity=Modification::class, inversedBy="selectionWipers")
  24.      * @Serializer\Groups({"collection"}) 
  25.      */
  26.     private $modification;
  27.     /**
  28.      * @ORM\Column(type="string", length=255, nullable=true)
  29.      * @Serializer\Groups({"collection", "selection/data"}) 
  30.      */
  31.     private $size1;
  32.     /**
  33.      * @ORM\Column(type="string", length=255, nullable=true)
  34.      * @Serializer\Groups({"collection", "selection/data"}) 
  35.      */
  36.     private $size2;
  37.     /**
  38.      * @ORM\ManyToOne(targetEntity=Fastener::class, inversedBy="selectionWipers")
  39.      * @ORM\JoinColumn(nullable=true)
  40.      * @Serializer\Groups({"collection", "selection/data"}) 
  41.      */
  42.     private $fastener;
  43.     /**
  44.      * @ORM\ManyToOne(targetEntity=ProductArticle::class, inversedBy="selectionWipers")
  45.      * @Serializer\Groups({"collection"}) 
  46.      */
  47.     private $productArticle;
  48.     public function getId(): ?int
  49.     {
  50.         return $this->id;
  51.     }
  52.     public function getModification(): ?Modification
  53.     {
  54.         return $this->modification;
  55.     }
  56.     public function setModification(?Modification $modification): self
  57.     {
  58.         $this->modification $modification;
  59.         return $this;
  60.     }
  61.     public function getFastener(): ?Fastener
  62.     {
  63.         return $this->fastener;
  64.     }
  65.     public function setFastener(?Fastener $fastener): self
  66.     {
  67.         $this->fastener $fastener;
  68.         return $this;
  69.     }
  70.     public function getSize1(): ?string
  71.     {
  72.         return $this->size1;
  73.     }
  74.     public function setSize1(?string $size1): self
  75.     {
  76.         $this->size1 $size1;
  77.         return $this;
  78.     }
  79.     public function getSize2(): ?string
  80.     {
  81.         return $this->size2;
  82.     }
  83.     public function setSize2(?string $size2): self
  84.     {
  85.         $this->size2 $size2;
  86.         return $this;
  87.     }
  88.     public function getProductArticle(): ?ProductArticle
  89.     {
  90.         return $this->productArticle;
  91.     }
  92.     public function setProductArticle(?ProductArticle $productArticle): self
  93.     {
  94.         $this->productArticle $productArticle;
  95.         return $this;
  96.     }
  97.     /**
  98.      * @Serializer\Groups({"selection/applicable"}) 
  99.      * @SerializedName("title")
  100.      */
  101.     public function getApplicableTitle(): string
  102.     {
  103.         $title '';
  104.         
  105.         if ($modification $this->getModification()) {
  106.             $title $modification->getModel()->getMark()->getTitle() . ' ' $modification->getModel()->getTitle() . ' [' $modification->getParams() .']';
  107.         }
  108.         return $title;
  109.     }
  110.     /**
  111.      * @Serializer\Groups({"selection/applicable"}) 
  112.      */
  113.     public function getRef(): array
  114.     {
  115.         if ($modification $this->getModification()) {
  116.             return [
  117.                 //'modification' => $modification->getId(),
  118.                 'mark' => $modification->getModel()->getMark()->getId(),
  119.                 'model' => $modification->getModel()->getId(),
  120.                 'body' => $modification->getBody(),
  121.                 'years' => ($modification->getYearFrom() ?? '') . '|' . ($modification->getYearTo() ?? '')
  122.             ];
  123.         }
  124.         return [];
  125.     }
  126. }