<?php
namespace App\Entity;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity(repositoryClass="App\Repository\CategoryRepository")
*
* @ORM\HasLifecycleCallbacks()
*/
class Category
{
public function __construct()
{
$this->menus = new ArrayCollection();
$this->channels = new ArrayCollection();
$this->children = new ArrayCollection();
$this->articleCategories = new ArrayCollection();
$this->rssFeedCategories = new ArrayCollection();
$this->userCategories = new ArrayCollection();
}
/**
* @ORM\Id()
*
* @ORM\GeneratedValue()
*
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\Column(type="string", nullable=false, length=180)
*/
private $name = null;
/**
* @ORM\Column(type="string", nullable=true, length=180)
*/
private $slug;
public function getId(): ?int
{
return $this->id;
}
public function getName()
{
return $this->name;
}
public function setName($name)
{
$this->name = $name;
return $this;
}
/**
* @return mixed
*/
public function getSlug()
{
return $this->slug;
}
/**
* @param mixed $slug
*
* @return Category
*/
public function setSlug($slug)
{
$this->slug = $slug;
return $this;
}
/**
* @ORM\Column(type="datetime", nullable=false)
*/
private $created_at;
/**
* @ORM\Column(type="datetime", nullable=true)
*/
private $updated_at = null;
public function getCreatedAt()
{
return $this->created_at;
}
public function setCreatedAt($created_at)
{
$this->created_at = $created_at;
return $this;
}
public function getUpdatedAt()
{
return $this->updated_at;
}
public function setUpdatedAt($updated_at)
{
$this->updated_at = $updated_at;
return $this;
}
/**
* @ORM\PrePersist
*/
public function setCreatedAtValue()
{
$this->setCreatedAt(new \DateTime());
}
/**
* @ORM\PreUpdate
*/
public function setUpdatedAtValue()
{
$this->setUpdatedAt(new \DateTime());
}
/**
* @ORM\Column(type="datetime", nullable=true)
*/
private $deleted_at;
/**
* @ORM\OneToMany(targetEntity="App\Entity\ChannelMenu", mappedBy="category")
*/
private $menus;
/**
* @ORM\ManyToOne(targetEntity="App\Entity\Category", inversedBy="children")
*
* @ORM\JoinColumn(nullable=true)
*/
private $parent;
public function getParent(): ?self
{
return $this->parent;
}
public function setParent(?self $parent): self
{
$this->parent = $parent;
return $this;
}
public function getDeletedAt(): ?\DateTimeInterface
{
return $this->deleted_at;
}
public function setDeletedAt(?\DateTimeInterface $deleted_at): self
{
$this->deleted_at = $deleted_at;
return $this;
}
/**
* @return Collection|ChannelMenu[]
*/
public function getMenus(): Collection
{
return $this->menus;
}
public function addMenu(ChannelMenu $menu): self
{
if (!$this->menus->contains($menu)) {
$this->menus[] = $menu;
$menu->setCategory($this);
}
return $this;
}
public function removeMenu(ChannelMenu $menu): self
{
if ($this->menus->contains($menu)) {
$this->menus->removeElement($menu);
// set the owning side to null (unless already changed)
if ($menu->getCategory() === $this) {
$menu->setCategory(null);
}
}
return $this;
}
/**
* @ORM\OneToMany(targetEntity="App\Entity\ChannelCategory", mappedBy="category")
*/
private $channels;
/**
* @return Collection|ChannelCategory[]
*/
public function getChannels(): Collection
{
return $this->channels;
}
public function addChannel(ChannelCategory $channel): self
{
if (!$this->channels->contains($channel)) {
$this->channels[] = $channel;
$channel->setCategory($this);
}
return $this;
}
public function removeChannel(ChannelCategory $channel): self
{
if ($this->channels->contains($channel)) {
$this->channels->removeElement($channel);
// set the owning side to null (unless already changed)
if ($channel->getCategory() === $this) {
$channel->setCategory(null);
}
}
return $this;
}
/**
* @ORM\OneToMany(targetEntity="App\Entity\Category", mappedBy="parent")
*/
private $children;
/**
* @ORM\OneToMany(targetEntity="App\Entity\ArticleCategory", mappedBy="category")
*/
private $articleCategories;
/**
* @ORM\OneToMany(targetEntity="App\Entity\RssFeedCategory", mappedBy="category")
*/
private $rssFeedCategories;
/**
* @ORM\OneToMany(targetEntity="App\Entity\NewsletterCategory", mappedBy="category")
*/
private $newsletterCategories;
/**
* @ORM\OneToMany(targetEntity="App\Entity\UserCategory", mappedBy="category")
*/
private $userCategories;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $color;
/**
* @ORM\Column(type="integer", nullable=true)
*/
private $legacy_id;
/**
* @return Collection|Category[]
*/
public function getChildren(): Collection
{
return $this->children;
}
public function addCategory(self $category): self
{
if (!$this->children->contains($category)) {
$this->children[] = $category;
$category->setParent($this);
}
return $this;
}
public function removeCategory(self $category): self
{
if ($this->children->contains($category)) {
$this->children->removeElement($category);
if ($category->getParent() === $this) {
$category->setParent(null);
}
}
return $this;
}
/**
* @return Collection|ArticleCategory[]
*/
public function getArticleCategories(): Collection
{
return $this->articleCategories;
}
public function addArticleCategory(ArticleCategory $articleCategory): self
{
if (!$this->articleCategories->contains($articleCategory)) {
$this->articleCategories[] = $articleCategory;
$articleCategory->setCategory($this);
}
return $this;
}
public function removeArticleCategory(ArticleCategory $articleCategory): self
{
if ($this->articleCategories->contains($articleCategory)) {
$this->articleCategories->removeElement($articleCategory);
// set the owning side to null (unless already changed)
if ($articleCategory->getCategory() === $this) {
$articleCategory->setCategory(null);
}
}
return $this;
}
/**
* @return Collection|RssFeedCategory[]
*/
public function getRssFeedCategories(): Collection
{
return $this->rssFeedCategories;
}
public function addRssFeedCategory(RssFeedCategory $rssFeedCategory): self
{
if (!$this->rssFeedCategories->contains($rssFeedCategory)) {
$this->rssFeedCategories[] = $rssFeedCategory;
$rssFeedCategory->setCategory($this);
}
return $this;
}
public function removeRssFeedCategory(RssFeedCategory $rssFeedCategory): self
{
if ($this->rssFeedCategories->contains($rssFeedCategory)) {
$this->rssFeedCategories->removeElement($rssFeedCategory);
// set the owning side to null (unless already changed)
if ($rssFeedCategory->getCategory() === $this) {
$rssFeedCategory->setCategory(null);
}
}
return $this;
}
/**
* @return Collection|UserCategory[]
*/
public function getUserCategoriesCategories(): Collection
{
return $this->userCategories;
}
// public function addUserCategorieseCategory(UserCategory $userCategory): self
// {
// if (!$this->userCategories->contains($userCategory)) {
// $this->userCategories[] = $userCategory;
// $userCategory->setCategory($this);
// }
//
// return $this;
// }
//
// public function removeUserCategory(UserCategory $userCategory): self
// {
// if ($this->userCategories->contains($userCategory)) {
// $this->userCategories->removeElement($userCategory);
// // set the owning side to null (unless already changed)
// if ($userCategory->getCategory() === $this) {
// $userCategory->setCategory(null);
// }
// }
//
// return $this;
// }
/**
* @return Collection|NewsletterCategory[]
*/
public function getNewsletterCategories(): Collection
{
return $this->newsletterCategories;
}
public function addNewsletterCategory(NewsletterCategory $newsletterCategory): self
{
if (!$this->newsletterCategories->contains($newsletterCategory)) {
$this->newsletterCategories[] = $newsletterCategory;
$newsletterCategory->setCategory($this);
}
return $this;
}
public function removeNewsletterCategory(NewsletterCategory $newsletterCategory): self
{
if ($this->newsletterCategories->contains($newsletterCategory)) {
$this->newsletterCategories->removeElement($newsletterCategory);
// set the owning side to null (unless already changed)
if ($newsletterCategory->getCategory() === $this) {
$newsletterCategory->setCategory(null);
}
}
return $this;
}
public function getColor(): ?string
{
return $this->color;
}
public function setColor(?string $color): self
{
$this->color = $color;
return $this;
}
public function getLegacyId(): ?int
{
return $this->legacy_id;
}
public function setLegacyId(?int $legacy_id): self
{
$this->legacy_id = $legacy_id;
return $this;
}
}