src/Entity/Marker.php line 21

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