<?php
namespace App\Entity;
use Knp\DoctrineBehaviors\Contract\Entity\SoftDeletableInterface;
use Knp\DoctrineBehaviors\Model\SoftDeletable\SoftDeletableTrait;
use Knp\DoctrineBehaviors\Contract\Entity\TimestampableInterface;
use Knp\DoctrineBehaviors\Model\Timestampable\TimestampableTrait;
use Knp\DoctrineBehaviors\Contract\Entity\BlameableInterface;
use Knp\DoctrineBehaviors\Model\Blameable\BlameableTrait;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Symfony\Contracts\Translation\TranslatorInterface;
/**
* @Doctrine\ORM\Mapping\Entity
* @Doctrine\ORM\Mapping\Table(name="marker")
*/
class Marker implements BlameableInterface, TimestampableInterface, SoftDeletableInterface {
use BlameableTrait;
use TimestampableTrait;
use SoftDeletableTrait;
const GREEN = 'green';
const RED = 'red';
const YELLOW = 'yellow';
static public function getColors(TranslatorInterface $translator, $locale) {
return [
$translator->trans(self::GREEN, [], 'admin', $locale) => self::GREEN,
$translator->trans(self::RED, [], 'admin', $locale) => self::RED,
$translator->trans(self::YELLOW, [], 'admin', $locale) => self::YELLOW,
];
}
/**
* Many Groups have Many Users.
* @Doctrine\ORM\Mapping\ManyToMany(targetEntity="App\Entity\Product", mappedBy="markers")
*/
private $products;
/**
* @Doctrine\ORM\Mapping\Id
* @Doctrine\ORM\Mapping\Column(type="integer")
* @Doctrine\ORM\Mapping\GeneratedValue(strategy="AUTO")
*/
protected $id;
/**
* @Doctrine\ORM\Mapping\Column(type="text", name="content")
*/
protected $content;
/**
* @Doctrine\ORM\Mapping\Column(type="string", length=255, name="color")
*/
protected $color;
/**
* @Doctrine\ORM\Mapping\ManyToOne(targetEntity="App\Entity\Language")
* @Doctrine\ORM\Mapping\JoinColumn(name="language", referencedColumnName="id")
*/
protected $language;
/**
* @Doctrine\ORM\Mapping\ManyToOne(targetEntity="App\Entity\ProductProducer", inversedBy="markers")
* @Doctrine\ORM\Mapping\JoinColumn(name="product_producer_id", referencedColumnName="id")
*/
protected $productProducer;
/**
* @Doctrine\ORM\Mapping\ManyToOne(targetEntity="App\Entity\LandingPage", inversedBy="markers")
* @Doctrine\ORM\Mapping\JoinColumn(name="landing_page_id", referencedColumnName="id")
*/
protected $landingPage;
public function __construct()
{
$this->products = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getContent(): ?string
{
return $this->content;
}
public function setContent(string $content): self
{
$this->content = $content;
return $this;
}
public function getColor(): ?string
{
return $this->color;
}
public function setColor(string $color): self
{
$this->color = $color;
return $this;
}
public function getLanguage(): ?Language
{
return $this->language;
}
public function setLanguage(?Language $language): self
{
$this->language = $language;
return $this;
}
public function getProductProducer(): ?ProductProducer
{
return $this->productProducer;
}
public function setProductProducer(?ProductProducer $productProducer): self
{
$this->productProducer = $productProducer;
return $this;
}
public function getLandingPage(): ?LandingPage
{
return $this->landingPage;
}
public function setLandingPage(?LandingPage $landingPage): self
{
$this->landingPage = $landingPage;
return $this;
}
/**
* @return Collection|Product[]
*/
public function getProducts(): Collection
{
return $this->products;
}
public function addProduct(Product $product): self
{
if (!$this->products->contains($product)) {
$this->products[] = $product;
$product->addMarker($this);
}
return $this;
}
public function removeProduct(Product $product): self
{
if ($this->products->contains($product)) {
$this->products->removeElement($product);
$product->removeMarker($this);
}
return $this;
}
}