src/Entity/MenuItem.php line 19
- <?php
- namespace App\Entity;
- use Gedmo\Mapping\Annotation as Gedmo;
- use Doctrine\ORM\Mapping as ORM;
- use A2lix\TranslationFormBundle\Util\Knp\KnpTranslatable;
- use Knp\DoctrineBehaviors\Contract\Entity\TranslatableInterface;
- use Knp\DoctrineBehaviors\Model\Translatable\TranslatableTrait;
- /**
- *
- * @ORM\Table(name="menu_item")
- * @ORM\Entity(repositoryClass="Gedmo\Tree\Entity\Repository\MaterializedPathRepository")
- * @ORM\Entity(repositoryClass="App\Repository\MenuItemRepository")
- * @Gedmo\Tree(type="materializedPath")
- * @ORM\HasLifecycleCallbacks()
- */
- class MenuItem implements TranslatableInterface
- {
- /* Begin Translatable */
- use TranslatableTrait;
- public function __call($method, $arguments)
- {
- return $this->proxyCurrentLocaleTranslation($method, $arguments);
- }
- protected $titulo;
- public function getTitulo()
- {
- return $this->translate()->getTitulo();
- }
- /* End Translatable */
- /**
- * @var integer
- *
- * @ORM\Column(name="id", type="integer")
- * @ORM\Id
- * @ORM\GeneratedValue
- * @Gedmo\TreePathSource
- */
- private $id;
- /**
- * @Gedmo\TreePath(separator=":", startsWithSeparator=true, endsWithSeparator=false,appendId=false)
- * @ORM\Column(name="path", type="string", length=3000, nullable=true )
- */
- private $path;
- /**
- * @Gedmo\TreeParent
- * @ORM\ManyToOne(targetEntity="MenuItem", inversedBy="children")
- * @ORM\JoinColumns({
- * @ORM\JoinColumn(name="parent_id", referencedColumnName="id", onDelete="CASCADE")
- * })
- * @Gedmo\SortableGroup
- */
- private $parent;
- /**
- * @Gedmo\TreeLevel
- * @ORM\Column(name="lvl", type="integer", nullable=true)
- */
- private $level;
- /**
- * @ORM\OneToMany(targetEntity="MenuItem", mappedBy="parent")
- */
- private $children;
- /**
- * @Gedmo\SortablePosition
- * @ORM\Column(name="position", type="integer")
- */
- private $position;
- /**
- * @ORM\ManyToOne(targetEntity="Menu", inversedBy="items", cascade={"persist"})
- * @ORM\JoinColumn(name="menu_id", referencedColumnName="id")
- * @Gedmo\SortableGroup
- */
- private $menu;
- /**
- * @var string
- *
- * @ORM\ManyToOne(targetEntity="App\Entity\Imagen")
- * @ORM\JoinColumn(name="imagen_id", nullable=true)
- */
- protected $imagen;
- /**
- * @ORM\Column(name="tipo", type="string", length=64)
- */
- private $tipo;
- /**
- * @ORM\Column(name="target", type="string", length=20)
- */
- private $target;
- /**
- * @ORM\Column(name="contenido", type="integer", nullable=true)
- */
- private $contenido;
- /**
- * @var boolean
- *
- * @ORM\Column(name="activo", type="boolean", options={"default":1})
- */
- private $activo;
- public function __construct() {
- $this->target = "_self";
- }
- public function getProductos() {
- return $this->productos;
- }
- public function getId()
- {
- return $this->id;
- }
- public function setParent(MenuItem $parent = null)
- {
- $this->parent = $parent;
- return $this;
- }
- public function getParent()
- {
- return $this->parent;
- }
- public function setPath($path)
- {
- $this->path = $path;
- return $this;
- }
- public function getPath()
- {
- return $this->path;
- }
- public function getLevel()
- {
- return $this->level;
- }
- public function setPosition($position)
- {
- $this->position = $position;
- return $this;
- }
- public function getPosition()
- {
- return $this->position;
- }
- public function setMenu(Menu $menu)
- {
- $this->menu = $menu;
- return $this;
- }
- public function getMenu()
- {
- return $this->menu;
- }
- /**
- * Set imagen
- *
- * @param media $imagen
- * @return Media
- */
- public function setImagen($imagen)
- {
- $this->imagen = $imagen;
- return $this;
- }
- /**
- * Get imagen
- *
- * @return media
- */
- public function getImagen()
- {
- return $this->imagen;
- }
- /**
- * Set tipo
- *
- * @param string $tipo
- * @return MenuItem
- */
- public function setTipo($tipo)
- {
- $this->tipo = $tipo;
- return $this;
- }
- /**
- * Get tipo
- *
- * @return string
- */
- public function getTipo()
- {
- return $this->tipo;
- }
- /**
- * Set target
- *
- * @param string $target
- * @return MenuItem
- */
- public function setTarget($target)
- {
- $this->target = $target;
- return $this;
- }
- /**
- * Get target
- *
- * @return string
- */
- public function getTarget()
- {
- return $this->target;
- }
- /**
- * Set contenido
- *
- * @param object $contenido
- * @return MenuItem
- */
- public function setContenido($contenido)
- {
- $this->contenido = $contenido;
- return $this;
- }
- /**
- * Get contenido
- *
- * @return object
- */
- public function getContenido()
- {
- return $this->contenido;
- }
- public static function getTipoLista()
- {
- return array_merge(Contenido::getTipoLista(), array(
- 'Familia',
- 'Enlace',
- 'Vacio',
- ));
- }
- public function __toString()
- {
- return str_repeat('-',($this->getLevel() * 3)).' '.$this->getTitulo();
- }
- /**
- * Set activo
- *
- * @param boolean $activo
- * @return Pais
- */
- public function setActivo($activo)
- {
- $this->activo = $activo;
- return $this;
- }
- /**
- * Get activo
- *
- * @return boolean
- */
- public function getActivo()
- {
- return $this->activo;
- }
- }