src/Entity/Marker.php line 25

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use Knp\DoctrineBehaviors\Contract\Entity\SoftDeletableInterface;
  4. use Knp\DoctrineBehaviors\Model\SoftDeletable\SoftDeletableTrait;
  5. use Knp\DoctrineBehaviors\Contract\Entity\TimestampableInterface;
  6. use Knp\DoctrineBehaviors\Model\Timestampable\TimestampableTrait;
  7. use Knp\DoctrineBehaviors\Contract\Entity\BlameableInterface;
  8. use Knp\DoctrineBehaviors\Model\Blameable\BlameableTrait;
  9. use Doctrine\Common\Collections\ArrayCollection;
  10. use Doctrine\Common\Collections\Collection;
  11. use Symfony\Contracts\Translation\TranslatorInterface;
  12. /**
  13.  * @Doctrine\ORM\Mapping\Entity
  14.  * @Doctrine\ORM\Mapping\Table(name="marker")
  15.  */
  16. class Marker implements BlameableInterfaceTimestampableInterfaceSoftDeletableInterface  {
  17.     use BlameableTrait;
  18.     use TimestampableTrait;
  19.     
  20.     use SoftDeletableTrait;
  21.     
  22. const GREEN 'green';
  23.     const RED 'red';
  24.     const YELLOW 'yellow';
  25.     static public function getColors(TranslatorInterface $translator$locale) {
  26.         return [
  27.             $translator->trans(self::GREEN, [], 'admin'$locale) => self::GREEN,
  28.             $translator->trans(self::RED, [], 'admin'$locale) => self::RED,
  29.             $translator->trans(self::YELLOW, [], 'admin'$locale) => self::YELLOW,
  30.         ];
  31.     }
  32.     /**
  33.      * Many Groups have Many Users.
  34.      * @Doctrine\ORM\Mapping\ManyToMany(targetEntity="App\Entity\Product", mappedBy="markers")
  35.      */
  36.     private $products;
  37.     /**
  38.      * @Doctrine\ORM\Mapping\Id
  39.      * @Doctrine\ORM\Mapping\Column(type="integer")
  40.      * @Doctrine\ORM\Mapping\GeneratedValue(strategy="AUTO")
  41.      */
  42.     protected $id;
  43.     /**
  44.      * @Doctrine\ORM\Mapping\Column(type="text", name="content")
  45.      */
  46.     protected $content;
  47.     /**
  48.      * @Doctrine\ORM\Mapping\Column(type="string", length=255, name="color")
  49.      */
  50.     protected $color;
  51.     /**
  52.      * @Doctrine\ORM\Mapping\ManyToOne(targetEntity="App\Entity\Language")
  53.      * @Doctrine\ORM\Mapping\JoinColumn(name="language", referencedColumnName="id")
  54.      */
  55.     protected $language;
  56.     /**
  57.      * @Doctrine\ORM\Mapping\ManyToOne(targetEntity="App\Entity\ProductProducer", inversedBy="markers")
  58.      * @Doctrine\ORM\Mapping\JoinColumn(name="product_producer_id", referencedColumnName="id")
  59.      */
  60.     protected $productProducer;
  61.     /**
  62.      * @Doctrine\ORM\Mapping\ManyToOne(targetEntity="App\Entity\LandingPage", inversedBy="markers")
  63.      * @Doctrine\ORM\Mapping\JoinColumn(name="landing_page_id", referencedColumnName="id")
  64.      */
  65.     protected $landingPage;
  66.     public function __construct()
  67.     {
  68.         $this->products = new ArrayCollection();
  69.     }
  70.     public function getId(): ?int
  71.     {
  72.         return $this->id;
  73.     }
  74.     public function getContent(): ?string
  75.     {
  76.         return $this->content;
  77.     }
  78.     public function setContent(string $content): self
  79.     {
  80.         $this->content $content;
  81.         return $this;
  82.     }
  83.     public function getColor(): ?string
  84.     {
  85.         return $this->color;
  86.     }
  87.     public function setColor(string $color): self
  88.     {
  89.         $this->color $color;
  90.         return $this;
  91.     }
  92.     public function getLanguage(): ?Language
  93.     {
  94.         return $this->language;
  95.     }
  96.     public function setLanguage(?Language $language): self
  97.     {
  98.         $this->language $language;
  99.         return $this;
  100.     }
  101.     public function getProductProducer(): ?ProductProducer
  102.     {
  103.         return $this->productProducer;
  104.     }
  105.     public function setProductProducer(?ProductProducer $productProducer): self
  106.     {
  107.         $this->productProducer $productProducer;
  108.         return $this;
  109.     }
  110.     public function getLandingPage(): ?LandingPage
  111.     {
  112.         return $this->landingPage;
  113.     }
  114.     public function setLandingPage(?LandingPage $landingPage): self
  115.     {
  116.         $this->landingPage $landingPage;
  117.         return $this;
  118.     }
  119.     /**
  120.      * @return Collection|Product[]
  121.      */
  122.     public function getProducts(): Collection
  123.     {
  124.         return $this->products;
  125.     }
  126.     public function addProduct(Product $product): self
  127.     {
  128.         if (!$this->products->contains($product)) {
  129.             $this->products[] = $product;
  130.             $product->addMarker($this);
  131.         }
  132.         return $this;
  133.     }
  134.     public function removeProduct(Product $product): self
  135.     {
  136.         if ($this->products->contains($product)) {
  137.             $this->products->removeElement($product);
  138.             $product->removeMarker($this);
  139.         }
  140.         return $this;
  141.     }
  142. }