<?php
namespace App\Entity;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Doctrine\Common\Collections\Criteria;
/**
* @ORM\Entity(repositoryClass="App\Repository\SiteRepository")
*/
class Site
{
const SITE_RCS = 1;
const SITE_AAR = 2;
const SITE_MCS = 3;
const SITE_CCS = 4;
/**
* @ORM\Id()
* @ORM\GeneratedValue()
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\Column(type="string", length=255)
*/
private $name;
/**
* @ORM\Column(type="string", length=255)
*/
private $meta_title;
/**
* @ORM\ManyToMany(targetEntity="App\Entity\Content", mappedBy="site")
*/
private $content;
/**
* @ORM\ManyToMany(targetEntity="App\Entity\Category", mappedBy="site")
*/
private $categories;
/**
* @ORM\ManyToMany(targetEntity="App\Entity\MediaGroupItem", mappedBy="site")
*/
private $media_group_items;
/**
* @ORM\ManyToMany(targetEntity="App\Entity\Customer", mappedBy="site")
*/
private $customers;
/**
* @ORM\ManyToMany(targetEntity="App\Entity\Poll", mappedBy="site")
*/
private $polls;
/**
* @ORM\ManyToMany(targetEntity="App\Entity\Quiz", mappedBy="site")
*/
private $quizzes;
/* *
* @ ORM\OneToMany(targetEntity="App\Entity\CustomerSiteLevel", mappedBy="customer", orphanRemoval=true, cascade={"persist", "remove"})
* /
private $levels;*/
public function __construct ()
{
$this->name = "";
$this->meta_title = "";
$this->content = new ArrayCollection();
$this->categories = new ArrayCollection();
$this->media_group_items = new ArrayCollection();
$this->customers = new ArrayCollection();
$this->polls = new ArrayCollection();
$this->quizzes = new ArrayCollection();
}
public function getId()
{
return $this->id;
}
/*public function getVersion() {
return $this->version;
}*/
public function getName(): string
{
return $this->name;
}
public function setName(string $name): self
{
$this->name = $name;
return $this;
}
public function getMetaTitle(): string
{
return $this->meta_title;
}
public function setMetaTitle(string $meta_title): self
{
$this->meta_title = $meta_title;
return $this;
}
public function getContent (): Collection
{
return $this->content;
}
public function addContent (Content $content)
{
if (!$this->content->contains($content)) {
$this->content[] = $content;
$content->addSite($this);
}
return $this;
}
public function removeContent (Content $content): self
{
if ($this->content->contains($content)) {
$this->content->removeElement($content);
$content->removeSite($this);
}
return $this;
}
public function getCategories (): Collection
{
return $this->categories;
}
public function addCategory (Category $categories)
{
if (!$this->categories->contains($categories)) {
$this->categories[] = $categories;
$categories->addSite($this);
}
return $this;
}
public function removeCategory (Category $categories): self
{
if ($this->categories->contains($categories)) {
$this->categories->removeElement($categories);
$categories->removeSite($this);
}
return $this;
}
public function getMediaGroupItems (): Collection
{
return $this->media_group_items;
}
public function addMediaGroupItem (MediaGroupItem $media_group_item)
{
if (!$this->media_group_items->contains($media_group_item)) {
$this->media_group_items[] = $media_group_item;
$media_group_item->addSite($this);
}
return $this;
}
public function removeMediaGroupItem (MediaGroupItem $media_group_item): self
{
if ($this->media_group_items->contains($media_group_item)) {
$this->media_group_items->removeElement($media_group_item);
$media_group_item->removeSite($this);
}
return $this;
}
public function getCustomers (): Collection
{
return $this->customers;
}
public function addCustomer (Customer $customer)
{
if (!$this->customers->contains($customer)) {
$this->customers[] = $customer;
$customer->addSite($this);
}
return $this;
}
public function removeCustomer (Customer $customer): self
{
if ($this->customers->contains($customer)) {
$this->customers->removeElement($customer);
$customer->removeSite($this);
}
return $this;
}
public function getPolls (): Collection
{
return $this->polls;
}
public function addPoll (Poll $poll)
{
if (!$this->polls->contains($poll)) {
$this->polls[] = $poll;
$poll->addSite($this);
}
return $this;
}
public function removePoll (Poll $poll): self
{
if ($this->polls->contains($poll)) {
$this->polls->removeElement($poll);
$poll->removeSite($this);
}
return $this;
}
public function getquizzes (): Collection
{
return $this->quizzes;
}
public function addQuiz (Quiz $quiz)
{
if (!$this->quizzes->contains($quiz)) {
$this->quizzes[] = $quiz;
$quiz->addSite($this);
}
return $this;
}
public function removeQuiz (Quiz $quiz): self
{
if ($this->quizzes->contains($quiz)) {
$this->quizzes->removeElement($quiz);
$quiz->removeSite($this);
}
return $this;
}
public function getSiteTextShort()
{
switch($this->id) {
case SELF::SITE_RCS:
return "RCS";
case SELF::SITE_AAR:
return "AAR";
case SELF::SITE_MCS:
return "MCS";
case SELF::SITE_CCS:
return "CCS";
}
return "";
}
//Should make this dynamic. Use SiteConfig or something.
public static function getSiteIdByCode($code)
{
switch($code) {
case "RCS":
return SELF::SITE_RCS;
case "AAR":
return SELF::SITE_AAR;
case "MCS":
return SELF::SITE_MCS;
case "CCS":
return SELF::SITE_CCS;
}
return "";
}
/*
public function getLevels(): Collection
{
return $this->levels;
}
public function addLevel(CustomerSiteLevel $level): self
{
if (!$this->levels->contains($level)) {
$this->levels[] = $level;
$level->setSite($this);
}
return $this;
}
public function resetLevels(): self
{
$this->levels = new ArrayCollection();
return $this;
}
*/
public function __toString ()
{
return $this->name ? $this->name : "";
}
}