src/Entity/Section.php line 13

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\SectionRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. /**
  8.  * @ORM\Entity(repositoryClass=SectionRepository::class)
  9.  */
  10. class Section
  11. {
  12.     /**
  13.      * @ORM\Id
  14.      * @ORM\GeneratedValue
  15.      * @ORM\Column(type="integer")
  16.      */
  17.     private $id;
  18.     /**
  19.      * @ORM\Column(type="string", length=100)
  20.      */
  21.     private $label;
  22.     /**
  23.      * @ORM\Column(type="boolean")
  24.      */
  25.     private $is_active;
  26.     /**
  27.      * @ORM\OneToMany(targetEntity=Article::class, mappedBy="section", orphanRemoval=true)
  28.      */
  29.     private $articles;
  30.     /**
  31.      * @ORM\OneToMany(targetEntity=Category::class, mappedBy="section", orphanRemoval=true)
  32.      */
  33.     private $categories;
  34.     public function __construct()
  35.     {
  36.         $this->articles = new ArrayCollection();
  37.     }
  38.     public function getId(): ?int
  39.     {
  40.         return $this->id;
  41.     }
  42.     public function getLabel(): ?string
  43.     {
  44.         return $this->label;
  45.     }
  46.     public function setLabel(string $label): self
  47.     {
  48.         $this->label $label;
  49.         return $this;
  50.     }
  51.     public function isIsActive(): ?bool
  52.     {
  53.         return $this->is_active;
  54.     }
  55.     public function setIsActive(bool $is_active): self
  56.     {
  57.         $this->is_active $is_active;
  58.         return $this;
  59.     }
  60.     /**
  61.      * @return Collection<int, Article>
  62.      */
  63.     public function getArticles(): Collection
  64.     {
  65.         return $this->articles;
  66.     }
  67.     public function addArticle(Article $article): self
  68.     {
  69.         if (!$this->articles->contains($article)) {
  70.             $this->articles[] = $article;
  71.             $article->setSection($this);
  72.         }
  73.         return $this;
  74.     }
  75.     public function removeArticle(Article $article): self
  76.     {
  77.         if ($this->articles->removeElement($article)) {
  78.             // set the owning side to null (unless already changed)
  79.             if ($article->getSection() === $this) {
  80.                 $article->setSection(null);
  81.             }
  82.         }
  83.         return $this;
  84.     }
  85.     /**
  86.      * @return Collection<int, Category>
  87.      */
  88.     public function getCategories(): Collection
  89.     {
  90.         return $this->categories;
  91.     }
  92.     public function addCategory(Category $category): self
  93.     {
  94.         if (!$this->categories->contains($category)) {
  95.             $this->categories[] = $category;
  96.             $category->setSection($this);
  97.         }
  98.         return $this;
  99.     }
  100.     public function removeCategory(Category $category): self
  101.     {
  102.         if ($this->categories->removeElement($category)) {
  103.             // set the owning side to null (unless already changed)
  104.             if ($category->getSection() === $this) {
  105.                 $category->setSection(null);
  106.             }
  107.         }
  108.         return $this;
  109.     }
  110. }