src/Entity/Site.php line 14

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use Doctrine\Common\Collections\ArrayCollection;
  4. use Doctrine\Common\Collections\Collection;
  5. use Doctrine\ORM\Mapping as ORM;
  6. use Doctrine\Common\Collections\Criteria;
  7. /**
  8.  * @ORM\Entity(repositoryClass="App\Repository\SiteRepository")
  9.  */
  10. class Site
  11. {
  12.     const SITE_RCS 1;
  13.     const SITE_AAR 2;
  14.     const SITE_MCS 3;
  15.     const SITE_CCS 4;
  16.     
  17.     /**
  18.      * @ORM\Id()
  19.      * @ORM\GeneratedValue()
  20.      * @ORM\Column(type="integer")
  21.      */
  22.     private $id;
  23.     
  24.     /**
  25.      * @ORM\Column(type="string", length=255)
  26.      */
  27.     private $name;
  28.     /**
  29.      * @ORM\Column(type="string", length=255)
  30.      */
  31.     private $meta_title;
  32.     
  33.     /**
  34.      * @ORM\ManyToMany(targetEntity="App\Entity\Content", mappedBy="site")
  35.      */
  36.     private $content;
  37.     
  38.     /**
  39.      * @ORM\ManyToMany(targetEntity="App\Entity\Category", mappedBy="site")
  40.      */
  41.     private $categories;
  42.     
  43.     /**
  44.      * @ORM\ManyToMany(targetEntity="App\Entity\MediaGroupItem", mappedBy="site")
  45.      */
  46.     private $media_group_items;
  47.     
  48.     /**
  49.      * @ORM\ManyToMany(targetEntity="App\Entity\Customer", mappedBy="site")
  50.      */
  51.     private $customers;
  52.     
  53.     /**
  54.      * @ORM\ManyToMany(targetEntity="App\Entity\Poll", mappedBy="site")
  55.      */
  56.     private $polls;
  57.     
  58.     /**
  59.      * @ORM\ManyToMany(targetEntity="App\Entity\Quiz", mappedBy="site")
  60.      */
  61.     private $quizzes;
  62.     /* *
  63.      * @ ORM\OneToMany(targetEntity="App\Entity\CustomerSiteLevel", mappedBy="customer", orphanRemoval=true, cascade={"persist", "remove"})
  64.      * /
  65.     private $levels;*/
  66.     
  67.     
  68.     public function __construct ()
  69.     {
  70.         $this->name "";
  71.         $this->meta_title "";
  72.         $this->content = new ArrayCollection();
  73.         $this->categories = new ArrayCollection();
  74.         $this->media_group_items = new ArrayCollection();
  75.         $this->customers = new ArrayCollection();
  76.         $this->polls = new ArrayCollection();
  77.         $this->quizzes = new ArrayCollection();
  78.     }
  79.     
  80.     public function getId()
  81.     {
  82.         return $this->id;
  83.     }
  84.     
  85.     /*public function getVersion() {
  86.         return $this->version;
  87.     }*/
  88.     
  89.     public function getName(): string
  90.     {
  91.         return $this->name;
  92.     }
  93.     
  94.     public function setName(string $name): self
  95.     {
  96.         $this->name $name;
  97.         return $this;
  98.     }
  99.     
  100.     public function getMetaTitle(): string
  101.     {
  102.         return $this->meta_title;
  103.     }
  104.     
  105.     public function setMetaTitle(string $meta_title): self
  106.     {
  107.         $this->meta_title $meta_title;
  108.         return $this;
  109.     }
  110.     
  111.     
  112.     public function getContent (): Collection
  113.     {
  114.         return $this->content;
  115.     }
  116.     
  117.     public function addContent (Content $content)
  118.     {
  119.         if (!$this->content->contains($content)) {
  120.             $this->content[] = $content;
  121.             $content->addSite($this);
  122.         }
  123.         return $this;
  124.     }
  125.     
  126.     public function removeContent (Content $content): self
  127.     {
  128.         if ($this->content->contains($content)) {
  129.             $this->content->removeElement($content);
  130.             $content->removeSite($this);
  131.         }
  132.         return $this;
  133.     }
  134.     
  135.     public function getCategories (): Collection
  136.     {
  137.         return $this->categories;
  138.     }
  139.     
  140.     public function addCategory (Category $categories)
  141.     {
  142.         if (!$this->categories->contains($categories)) {
  143.             $this->categories[] = $categories;
  144.             $categories->addSite($this);
  145.         }
  146.         return $this;
  147.     }
  148.     
  149.     public function removeCategory (Category $categories): self
  150.     {
  151.         if ($this->categories->contains($categories)) {
  152.             $this->categories->removeElement($categories);
  153.             $categories->removeSite($this);
  154.         }
  155.         return $this;
  156.     }
  157.     
  158.     public function getMediaGroupItems (): Collection
  159.     {
  160.         return $this->media_group_items;
  161.     }
  162.     
  163.     public function addMediaGroupItem (MediaGroupItem $media_group_item)
  164.     {
  165.         if (!$this->media_group_items->contains($media_group_item)) {
  166.             $this->media_group_items[] = $media_group_item;
  167.             $media_group_item->addSite($this);
  168.         }
  169.         return $this;
  170.     }
  171.     
  172.     public function removeMediaGroupItem (MediaGroupItem $media_group_item): self
  173.     {
  174.         if ($this->media_group_items->contains($media_group_item)) {
  175.             $this->media_group_items->removeElement($media_group_item);
  176.             $media_group_item->removeSite($this);
  177.         }
  178.         return $this;
  179.     }
  180.     
  181.     public function getCustomers (): Collection
  182.     {
  183.         return $this->customers;
  184.     }
  185.     
  186.     public function addCustomer (Customer $customer)
  187.     {
  188.         if (!$this->customers->contains($customer)) {
  189.             $this->customers[] = $customer;
  190.             $customer->addSite($this);
  191.         }
  192.         return $this;
  193.     }
  194.     
  195.     public function removeCustomer (Customer $customer): self
  196.     {
  197.         if ($this->customers->contains($customer)) {
  198.             $this->customers->removeElement($customer);
  199.             $customer->removeSite($this);
  200.         }
  201.         return $this;
  202.     }
  203.     
  204.     public function getPolls (): Collection
  205.     {
  206.         return $this->polls;
  207.     }
  208.     
  209.     public function addPoll (Poll $poll)
  210.     {
  211.         if (!$this->polls->contains($poll)) {
  212.             $this->polls[] = $poll;
  213.             $poll->addSite($this);
  214.         }
  215.         return $this;
  216.     }
  217.     
  218.     public function removePoll (Poll $poll): self
  219.     {
  220.         if ($this->polls->contains($poll)) {
  221.             $this->polls->removeElement($poll);
  222.             $poll->removeSite($this);
  223.         }
  224.         return $this;
  225.     }
  226.     
  227.     public function getquizzes (): Collection
  228.     {
  229.         return $this->quizzes;
  230.     }
  231.     
  232.     public function addQuiz (Quiz $quiz)
  233.     {
  234.         if (!$this->quizzes->contains($quiz)) {
  235.             $this->quizzes[] = $quiz;
  236.             $quiz->addSite($this);
  237.         }
  238.         return $this;
  239.     }
  240.     
  241.     public function removeQuiz (Quiz $quiz): self
  242.     {
  243.         if ($this->quizzes->contains($quiz)) {
  244.             $this->quizzes->removeElement($quiz);
  245.             $quiz->removeSite($this);
  246.         }
  247.         return $this;
  248.     }
  249.     
  250.     public function getSiteTextShort()
  251.     {
  252.         switch($this->id) {
  253.             case SELF::SITE_RCS:
  254.                 return "RCS";
  255.             case SELF::SITE_AAR:
  256.                 return "AAR";
  257.             case SELF::SITE_MCS:
  258.                 return "MCS";
  259.             case SELF::SITE_CCS:
  260.                 return "CCS";
  261.         }
  262.         return "";
  263.     }
  264.     
  265.     //Should make this dynamic. Use SiteConfig or something.
  266.     public static function getSiteIdByCode($code)
  267.     {
  268.         switch($code) {
  269.             case "RCS":
  270.                 return SELF::SITE_RCS;
  271.             case "AAR":
  272.                 return SELF::SITE_AAR;
  273.             case "MCS":
  274.                 return SELF::SITE_MCS;
  275.             case "CCS":
  276.                 return SELF::SITE_CCS;
  277.         }
  278.         return "";
  279.     }
  280.     
  281.     /*
  282.     public function getLevels(): Collection
  283.     {
  284.         return $this->levels;
  285.     }
  286.     public function addLevel(CustomerSiteLevel $level): self
  287.     {
  288.         if (!$this->levels->contains($level)) {
  289.             $this->levels[] = $level;
  290.             $level->setSite($this);
  291.         }
  292.         return $this;
  293.     }
  294.     
  295.     public function resetLevels(): self
  296.     {
  297.         $this->levels = new ArrayCollection();
  298.         return $this;
  299.     }
  300.     */
  301.     
  302.     public function __toString ()
  303.     {
  304.         return $this->name $this->name "";
  305.     }
  306.     
  307.     
  308. }