vendor/kunstmaan/menu-bundle/Entity/BaseMenu.php line 14

Open in your IDE?
  1. <?php
  2. namespace Kunstmaan\MenuBundle\Entity;
  3. use Doctrine\Common\Collections\ArrayCollection;
  4. use Doctrine\ORM\Mapping as ORM;
  5. use Kunstmaan\AdminBundle\Entity\EntityInterface;
  6. use Symfony\Component\Validator\Constraints as Assert;
  7. /**
  8.  * @ORM\MappedSuperclass()
  9.  */
  10. #[ORM\MappedSuperclass]
  11. class BaseMenu implements EntityInterface
  12. {
  13.     /**
  14.      * @ORM\Id
  15.      * @ORM\Column(type="bigint")
  16.      * @ORM\GeneratedValue(strategy="AUTO")
  17.      */
  18.     #[ORM\Id]
  19.     #[ORM\Column(name'id'type'bigint')]
  20.     #[ORM\GeneratedValue('AUTO')]
  21.     protected $id;
  22.     /**
  23.      * @var string
  24.      *
  25.      * @ORM\Column(name="name", type="string", length=25, nullable=true)
  26.      */
  27.     #[ORM\Column(name'name'type'string'length25nullabletrue)]
  28.     #[Assert\NotBlank]
  29.     #[Assert\Length(max25)]
  30.     protected $name;
  31.     /**
  32.      * @var string
  33.      *
  34.      * @ORM\Column(name="locale", type="string", length=5, nullable=true)
  35.      */
  36.     #[ORM\Column(name'locale'type'string'length5nullabletrue)]
  37.     #[Assert\NotBlank]
  38.     #[Assert\Length(max5)]
  39.     protected $locale;
  40.     /**
  41.      * @var ArrayCollection
  42.      *
  43.      * @ORM\OneToMany(targetEntity="Kunstmaan\MenuBundle\Entity\MenuItem", mappedBy="menu", cascade={"persist", "remove"}, orphanRemoval=true)
  44.      */
  45.     #[ORM\OneToMany(targetEntityMenuItem::class, mappedBy'menu'cascade: ['persist''remove'], orphanRemovaltrue)]
  46.     protected $items;
  47.     public function __construct()
  48.     {
  49.         $this->items = new ArrayCollection();
  50.     }
  51.     /**
  52.      * @return int
  53.      */
  54.     public function getId()
  55.     {
  56.         return $this->id;
  57.     }
  58.     /**
  59.      * @param int $id The unique identifier
  60.      *
  61.      * @return $this
  62.      */
  63.     public function setId($id)
  64.     {
  65.         $this->id $id;
  66.         return $this;
  67.     }
  68.     /**
  69.      * @return string
  70.      */
  71.     public function getName()
  72.     {
  73.         return $this->name;
  74.     }
  75.     /**
  76.      * @param string $name
  77.      *
  78.      * @return Menu
  79.      */
  80.     public function setName($name)
  81.     {
  82.         $this->name $name;
  83.         return $this;
  84.     }
  85.     /**
  86.      * @return string
  87.      */
  88.     public function getLocale()
  89.     {
  90.         return $this->locale;
  91.     }
  92.     /**
  93.      * @param string $locale
  94.      *
  95.      * @return Menu
  96.      */
  97.     public function setLocale($locale)
  98.     {
  99.         $this->locale $locale;
  100.         return $this;
  101.     }
  102.     /**
  103.      * @return ArrayCollection
  104.      */
  105.     public function getItems()
  106.     {
  107.         return $this->items;
  108.     }
  109.     /**
  110.      * @param ArrayCollection $items
  111.      *
  112.      * @return Menu
  113.      */
  114.     public function setItems($items)
  115.     {
  116.         $this->items $items;
  117.         return $this;
  118.     }
  119.     public function addItem(MenuItem $item)
  120.     {
  121.         $item->setMenu($this);
  122.         $this->items->add($item);
  123.     }
  124.     public function removeItem(MenuItem $item)
  125.     {
  126.         $this->items->removeElement($item);
  127.     }
  128.     /**
  129.      * Return string representation of entity
  130.      *
  131.      * @return string
  132.      */
  133.     public function __toString()
  134.     {
  135.         return (string) $this->getId();
  136.     }
  137. }