src/CmsBundle/Entity/WidgetCategory.php line 15

Open in your IDE?
  1. <?php
  2. namespace App\CmsBundle\Entity;
  3. use Doctrine\Common\Collections\Collection;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\ORM\Mapping as ORM;
  6. /**
  7.  * WidgetCategory
  8.  *
  9.  * @ORM\Table(name="widget_category")
  10.  * @ORM\Entity(repositoryClass="App\CmsBundle\Repository\WidgetCategoryRepository")
  11.  */
  12. class WidgetCategory
  13. {
  14.     use IdTrait;
  15.     /**
  16.      * @ORM\Column(name="name", type="string", nullable=false)
  17.      */
  18.     private string $title;
  19.     /**
  20.      * @ORM\ManyToMany(targetEntity=Widget::class, mappedBy="categories")
  21.      */
  22.     private Collection $widgets;
  23.     public function __construct()
  24.     {
  25.         $this->widgets = new ArrayCollection();
  26.     }
  27.     /**
  28.      * @return string
  29.      */
  30.     public function __toString(): string
  31.     {
  32.         return $this->title ?? '';
  33.     }
  34.     /**
  35.      * @return string
  36.      */
  37.     public function getTitle(): string
  38.     {
  39.         return $this->title;
  40.     }
  41.     public function getWidgets(): Collection
  42.     {
  43.         return $this->widgets;
  44.     }
  45.     /**
  46.      * @param string $title
  47.      * @return WidgetCategory
  48.      */
  49.     public function setTitle(string $title): self
  50.     {
  51.         $this->title $title;
  52.         return $this;
  53.     }
  54. }