src/Entity/Menu.php line 16

  1. <?php
  2. namespace App\Entity;
  3. use Doctrine\ORM\Mapping as ORM;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. /**
  6.  * Menu
  7.  *
  8.  * @ORM\Entity
  9.  * @ORM\Table(name="menu")
  10.  * @ORM\Entity(repositoryClass="App\Repository\MenuRepository")  
  11.  */
  12. class Menu
  13. {
  14.     const ZONA_PRINCIPAL 'principal';
  15.     const ZONA_PIE 'pie';
  16.     
  17.     public static function getZonaLista()
  18.     {
  19.         return array(
  20.                 self::ZONA_PRINCIPAL,    
  21.                 self::ZONA_PIE
  22.                 );
  23.     } 
  24.     
  25.     /**
  26.      * @var integer
  27.      * @ORM\Column(name="id", type="integer")
  28.      * @ORM\Id
  29.      * @ORM\GeneratedValue(strategy="AUTO")
  30.      */
  31.     private $id;
  32.     /**
  33.      * @var string
  34.      *
  35.      * @ORM\Column(name="nombre", type="string", length=64)
  36.      */
  37.     private $nombre;
  38.     
  39.     /**
  40.      * @var boolean
  41.      *
  42.      * @ORM\Column(name="activo", type="boolean", options={"default":0})
  43.      */
  44.     private $activo;
  45.     
  46.     /**
  47.      * @var Collection
  48.      * @ORM\OneToMany(targetEntity="MenuItem", mappedBy="menu" , cascade={"persist"}, orphanRemoval=true)
  49.      * @ORM\OrderBy({"position" = "ASC"})
  50.      */
  51.     protected $items;    
  52.     
  53.     /**
  54.      * @var string
  55.      *
  56.      * @ORM\Column(name="zona", type="string", length=64)
  57.      */
  58.     protected $zona;
  59.     
  60.     
  61.     public function __construct()
  62.     {
  63.         $this->items = new ArrayCollection();
  64.     }      
  65.     
  66.  
  67.     
  68.     public function getItems()
  69.     {
  70.         return $this->items;
  71.     }
  72.     
  73.     public function addItem(MenuItem $item)
  74.     {
  75.         if (!$this->items->contains($item))
  76.         {
  77.             $item->setMenu($this);
  78.             $this->items->add($item);
  79.         }
  80.     }
  81.     
  82.     public function removeItem(MenuItem $item)
  83.     {
  84.         if ($this->items->contains($item))
  85.             return $this->items->removeElement($item);
  86.     }     
  87.     
  88.     
  89.     public function __toString()
  90.     {
  91.         return $this->getNombre();
  92.     }
  93.     
  94.     /**
  95.      * Set id
  96.      *
  97.      * @param string $id
  98.      * @return Pais
  99.      */
  100.     public function setId($id)
  101.     {
  102.         $this->id $id;
  103.     
  104.         return $this;
  105.     }    
  106.     
  107.     /**
  108.      * Get id
  109.      *
  110.      * @return string 
  111.      */
  112.     public function getId()
  113.     {
  114.         return $this->id;
  115.     }
  116.     /**
  117.      * Set nombre
  118.      *
  119.      * @param string $nombre
  120.      * @return Pais
  121.      */
  122.     public function setNombre($nombre)
  123.     {
  124.         $this->nombre $nombre;
  125.     
  126.         return $this;
  127.     }
  128.     /**
  129.      * Get nombre
  130.      *
  131.      * @return string 
  132.      */
  133.     public function getNombre()
  134.     {
  135.         return $this->nombre;
  136.     }
  137.     
  138.     /**
  139.      * Set activo
  140.      *
  141.      * @param boolean $activo
  142.      * @return Pais
  143.      */
  144.     public function setActivo($activo)
  145.     {
  146.         $this->activo $activo;
  147.     
  148.         return $this;
  149.     }
  150.     /**
  151.      * Get activo
  152.      *
  153.      * @return boolean 
  154.      */
  155.     public function getActivo()
  156.     {
  157.         return $this->activo;
  158.     }  
  159.     
  160.     
  161.     /**
  162.      * Set zona
  163.      *
  164.      * @param string $zona
  165.      * @return Zona
  166.      */
  167.     public function setZona($zona)
  168.     {
  169.         $this->zona $zona;
  170.     
  171.         return $this;
  172.     }    
  173.     
  174.     /**
  175.      * Get zona
  176.      *
  177.      * @return string 
  178.      */
  179.     public function getZona()
  180.     {
  181.         return $this->zona;
  182.     }
  183.     
  184.     
  185. }