src/Entity/Category.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. /**
  7.  * @ORM\Entity(repositoryClass="App\Repository\CategoryRepository")
  8.  *
  9.  * @ORM\HasLifecycleCallbacks()
  10.  */
  11. class Category
  12. {
  13.     public function __construct()
  14.     {
  15.         $this->menus = new ArrayCollection();
  16.         $this->channels = new ArrayCollection();
  17.         $this->children = new ArrayCollection();
  18.         $this->articleCategories = new ArrayCollection();
  19.         $this->rssFeedCategories = new ArrayCollection();
  20.         $this->userCategories = new ArrayCollection();
  21.     }
  22.     /**
  23.      * @ORM\Id()
  24.      *
  25.      * @ORM\GeneratedValue()
  26.      *
  27.      * @ORM\Column(type="integer")
  28.      */
  29.     private $id;
  30.     /**
  31.      * @ORM\Column(type="string", nullable=false, length=180)
  32.      */
  33.     private $name null;
  34.     /**
  35.      * @ORM\Column(type="string", nullable=true, length=180)
  36.      */
  37.     private $slug;
  38.     public function getId(): ?int
  39.     {
  40.         return $this->id;
  41.     }
  42.     public function getName()
  43.     {
  44.         return $this->name;
  45.     }
  46.     public function setName($name)
  47.     {
  48.         $this->name $name;
  49.         return $this;
  50.     }
  51.     /**
  52.      * @return mixed
  53.      */
  54.     public function getSlug()
  55.     {
  56.         return $this->slug;
  57.     }
  58.     /**
  59.      * @param mixed $slug
  60.      *
  61.      * @return Category
  62.      */
  63.     public function setSlug($slug)
  64.     {
  65.         $this->slug $slug;
  66.         return $this;
  67.     }
  68.     /**
  69.      * @ORM\Column(type="datetime", nullable=false)
  70.      */
  71.     private $created_at;
  72.     /**
  73.      * @ORM\Column(type="datetime", nullable=true)
  74.      */
  75.     private $updated_at null;
  76.     public function getCreatedAt()
  77.     {
  78.         return $this->created_at;
  79.     }
  80.     public function setCreatedAt($created_at)
  81.     {
  82.         $this->created_at $created_at;
  83.         return $this;
  84.     }
  85.     public function getUpdatedAt()
  86.     {
  87.         return $this->updated_at;
  88.     }
  89.     public function setUpdatedAt($updated_at)
  90.     {
  91.         $this->updated_at $updated_at;
  92.         return $this;
  93.     }
  94.     /**
  95.      * @ORM\PrePersist
  96.      */
  97.     public function setCreatedAtValue()
  98.     {
  99.         $this->setCreatedAt(new \DateTime());
  100.     }
  101.     /**
  102.      * @ORM\PreUpdate
  103.      */
  104.     public function setUpdatedAtValue()
  105.     {
  106.         $this->setUpdatedAt(new \DateTime());
  107.     }
  108.     /**
  109.      * @ORM\Column(type="datetime", nullable=true)
  110.      */
  111.     private $deleted_at;
  112.     /**
  113.      * @ORM\OneToMany(targetEntity="App\Entity\ChannelMenu", mappedBy="category")
  114.      */
  115.     private $menus;
  116.     /**
  117.      * @ORM\ManyToOne(targetEntity="App\Entity\Category", inversedBy="children")
  118.      *
  119.      * @ORM\JoinColumn(nullable=true)
  120.      */
  121.     private $parent;
  122.     public function getParent(): ?self
  123.     {
  124.         return $this->parent;
  125.     }
  126.     public function setParent(?self $parent): self
  127.     {
  128.         $this->parent $parent;
  129.         return $this;
  130.     }
  131.     public function getDeletedAt(): ?\DateTimeInterface
  132.     {
  133.         return $this->deleted_at;
  134.     }
  135.     public function setDeletedAt(?\DateTimeInterface $deleted_at): self
  136.     {
  137.         $this->deleted_at $deleted_at;
  138.         return $this;
  139.     }
  140.     /**
  141.      * @return Collection|ChannelMenu[]
  142.      */
  143.     public function getMenus(): Collection
  144.     {
  145.         return $this->menus;
  146.     }
  147.     public function addMenu(ChannelMenu $menu): self
  148.     {
  149.         if (!$this->menus->contains($menu)) {
  150.             $this->menus[] = $menu;
  151.             $menu->setCategory($this);
  152.         }
  153.         return $this;
  154.     }
  155.     public function removeMenu(ChannelMenu $menu): self
  156.     {
  157.         if ($this->menus->contains($menu)) {
  158.             $this->menus->removeElement($menu);
  159.             // set the owning side to null (unless already changed)
  160.             if ($menu->getCategory() === $this) {
  161.                 $menu->setCategory(null);
  162.             }
  163.         }
  164.         return $this;
  165.     }
  166.     /**
  167.      * @ORM\OneToMany(targetEntity="App\Entity\ChannelCategory", mappedBy="category")
  168.      */
  169.     private $channels;
  170.     /**
  171.      * @return Collection|ChannelCategory[]
  172.      */
  173.     public function getChannels(): Collection
  174.     {
  175.         return $this->channels;
  176.     }
  177.     public function addChannel(ChannelCategory $channel): self
  178.     {
  179.         if (!$this->channels->contains($channel)) {
  180.             $this->channels[] = $channel;
  181.             $channel->setCategory($this);
  182.         }
  183.         return $this;
  184.     }
  185.     public function removeChannel(ChannelCategory $channel): self
  186.     {
  187.         if ($this->channels->contains($channel)) {
  188.             $this->channels->removeElement($channel);
  189.             // set the owning side to null (unless already changed)
  190.             if ($channel->getCategory() === $this) {
  191.                 $channel->setCategory(null);
  192.             }
  193.         }
  194.         return $this;
  195.     }
  196.     /**
  197.      * @ORM\OneToMany(targetEntity="App\Entity\Category", mappedBy="parent")
  198.      */
  199.     private $children;
  200.     /**
  201.      * @ORM\OneToMany(targetEntity="App\Entity\ArticleCategory", mappedBy="category")
  202.      */
  203.     private $articleCategories;
  204.     /**
  205.      * @ORM\OneToMany(targetEntity="App\Entity\RssFeedCategory", mappedBy="category")
  206.      */
  207.     private $rssFeedCategories;
  208.     /**
  209.      * @ORM\OneToMany(targetEntity="App\Entity\NewsletterCategory", mappedBy="category")
  210.      */
  211.     private $newsletterCategories;
  212.     /**
  213.      * @ORM\OneToMany(targetEntity="App\Entity\UserCategory", mappedBy="category")
  214.      */
  215.     private $userCategories;
  216.     /**
  217.      * @ORM\Column(type="string", length=255, nullable=true)
  218.      */
  219.     private $color;
  220.     /**
  221.      * @ORM\Column(type="integer", nullable=true)
  222.      */
  223.     private $legacy_id;
  224.     /**
  225.      * @return Collection|Category[]
  226.      */
  227.     public function getChildren(): Collection
  228.     {
  229.         return $this->children;
  230.     }
  231.     public function addCategory(self $category): self
  232.     {
  233.         if (!$this->children->contains($category)) {
  234.             $this->children[] = $category;
  235.             $category->setParent($this);
  236.         }
  237.         return $this;
  238.     }
  239.     public function removeCategory(self $category): self
  240.     {
  241.         if ($this->children->contains($category)) {
  242.             $this->children->removeElement($category);
  243.             if ($category->getParent() === $this) {
  244.                 $category->setParent(null);
  245.             }
  246.         }
  247.         return $this;
  248.     }
  249.     /**
  250.      * @return Collection|ArticleCategory[]
  251.      */
  252.     public function getArticleCategories(): Collection
  253.     {
  254.         return $this->articleCategories;
  255.     }
  256.     public function addArticleCategory(ArticleCategory $articleCategory): self
  257.     {
  258.         if (!$this->articleCategories->contains($articleCategory)) {
  259.             $this->articleCategories[] = $articleCategory;
  260.             $articleCategory->setCategory($this);
  261.         }
  262.         return $this;
  263.     }
  264.     public function removeArticleCategory(ArticleCategory $articleCategory): self
  265.     {
  266.         if ($this->articleCategories->contains($articleCategory)) {
  267.             $this->articleCategories->removeElement($articleCategory);
  268.             // set the owning side to null (unless already changed)
  269.             if ($articleCategory->getCategory() === $this) {
  270.                 $articleCategory->setCategory(null);
  271.             }
  272.         }
  273.         return $this;
  274.     }
  275.     /**
  276.      * @return Collection|RssFeedCategory[]
  277.      */
  278.     public function getRssFeedCategories(): Collection
  279.     {
  280.         return $this->rssFeedCategories;
  281.     }
  282.     public function addRssFeedCategory(RssFeedCategory $rssFeedCategory): self
  283.     {
  284.         if (!$this->rssFeedCategories->contains($rssFeedCategory)) {
  285.             $this->rssFeedCategories[] = $rssFeedCategory;
  286.             $rssFeedCategory->setCategory($this);
  287.         }
  288.         return $this;
  289.     }
  290.     public function removeRssFeedCategory(RssFeedCategory $rssFeedCategory): self
  291.     {
  292.         if ($this->rssFeedCategories->contains($rssFeedCategory)) {
  293.             $this->rssFeedCategories->removeElement($rssFeedCategory);
  294.             // set the owning side to null (unless already changed)
  295.             if ($rssFeedCategory->getCategory() === $this) {
  296.                 $rssFeedCategory->setCategory(null);
  297.             }
  298.         }
  299.         return $this;
  300.     }
  301.     /**
  302.      * @return Collection|UserCategory[]
  303.      */
  304.     public function getUserCategoriesCategories(): Collection
  305.     {
  306.         return $this->userCategories;
  307.     }
  308. //    public function addUserCategorieseCategory(UserCategory $userCategory): self
  309. //    {
  310. //        if (!$this->userCategories->contains($userCategory)) {
  311. //            $this->userCategories[] = $userCategory;
  312. //            $userCategory->setCategory($this);
  313. //        }
  314. //
  315. //        return $this;
  316. //    }
  317. //
  318. //    public function removeUserCategory(UserCategory $userCategory): self
  319. //    {
  320. //        if ($this->userCategories->contains($userCategory)) {
  321. //            $this->userCategories->removeElement($userCategory);
  322. //            // set the owning side to null (unless already changed)
  323. //            if ($userCategory->getCategory() === $this) {
  324. //                $userCategory->setCategory(null);
  325. //            }
  326. //        }
  327. //
  328. //        return $this;
  329. //    }
  330.     /**
  331.      * @return Collection|NewsletterCategory[]
  332.      */
  333.     public function getNewsletterCategories(): Collection
  334.     {
  335.         return $this->newsletterCategories;
  336.     }
  337.     public function addNewsletterCategory(NewsletterCategory $newsletterCategory): self
  338.     {
  339.         if (!$this->newsletterCategories->contains($newsletterCategory)) {
  340.             $this->newsletterCategories[] = $newsletterCategory;
  341.             $newsletterCategory->setCategory($this);
  342.         }
  343.         return $this;
  344.     }
  345.     public function removeNewsletterCategory(NewsletterCategory $newsletterCategory): self
  346.     {
  347.         if ($this->newsletterCategories->contains($newsletterCategory)) {
  348.             $this->newsletterCategories->removeElement($newsletterCategory);
  349.             // set the owning side to null (unless already changed)
  350.             if ($newsletterCategory->getCategory() === $this) {
  351.                 $newsletterCategory->setCategory(null);
  352.             }
  353.         }
  354.         return $this;
  355.     }
  356.     public function getColor(): ?string
  357.     {
  358.         return $this->color;
  359.     }
  360.     public function setColor(?string $color): self
  361.     {
  362.         $this->color $color;
  363.         return $this;
  364.     }
  365.     public function getLegacyId(): ?int
  366.     {
  367.         return $this->legacy_id;
  368.     }
  369.     public function setLegacyId(?int $legacy_id): self
  370.     {
  371.         $this->legacy_id $legacy_id;
  372.         return $this;
  373.     }
  374. }