<?php
namespace Roothirsch\CoreBundle\Menu\Entity;
use ApiPlatform\Core\Annotation\ApiResource;
use Roothirsch\CoreBundle\Menu\API\UpdateSorting;
use Roothirsch\CoreBundle\Menu\Repository\MenuItemRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Gedmo\Mapping\Annotation as Gedmo;
/**
*
* @ORM\Entity(repositoryClass=MenuItemRepository::class)
* @ORM\Table(name="menu_item")
* @Gedmo\Tree(type="nested")
* @ApiResource(
* shortName="Menu/MenuItem",
* itemOperations={
* "get",
* "put",
* "delete",
* "update_sorting"={
* "method"="PUT",
* "path"="/menu/menu_items/{id}/update-sorting",
* "controller"=UpdateSorting::class
* },
* }
* )
*/
class MenuItem
{
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\Column(type="string", length=255, nullable=true)
* @Gedmo\Translatable
*/
private $title;
/**
* @ORM\Column(type="string", length=255)
*/
private $type;
/**
* @ORM\Column(type="string", length=1024, nullable=true)
*/
private $icon;
/**
* @ORM\Column(type="string", length=1024, nullable=true)
*/
private $cssClass;
/**
* @ORM\Column(type="string", length=1024, nullable=true)
*/
private $entityFqcn;
/**
* @ORM\Column(type="string", length=1024, nullable=true)
*/
private $controllerFqcn;
/**
* @ORM\Column(type="string", length=1024, nullable=true)
*/
private $entityId;
/**
* @ORM\Column(type="string", length=1024, nullable=true)
*/
private $routeName;
/**
* @ORM\Column(type="string", length=1024, nullable=true)
*/
private $controllerAction;
/**
* @ORM\Column(type="string", length=255, nullable=true)
* @Gedmo\Translatable
*/
private $url;
/**
* @Gedmo\TreeLeft
* @ORM\Column(name="lft", type="integer")
*/
private $lft;
/**
* @Gedmo\TreeLevel
* @ORM\Column(name="lvl", type="integer")
*/
private $lvl;
/**
* @Gedmo\TreeRight
* @ORM\Column(name="rgt", type="integer")
*/
private $rgt;
/**
* @Gedmo\TreeRoot
* @ORM\ManyToOne(targetEntity="MenuItem")
* @ORM\JoinColumn(name="tree_root", referencedColumnName="id", onDelete="CASCADE")
*/
private $root;
/**
* @Gedmo\TreeParent
* @ORM\ManyToOne(targetEntity="MenuItem", inversedBy="children")
* @ORM\JoinColumn(name="parent_id", referencedColumnName="id", onDelete="CASCADE")
*/
private $parent;
/**
* @ORM\OneToMany(targetEntity="MenuItem", mappedBy="parent_id")
* @ORM\OrderBy({"lft" = "ASC"})
*/
private $children;
private ?array $config;
public function __construct()
{
$this->children = new ArrayCollection();
}
public function __toString()
{
return strval($this->title);
}
public function getId(): ?int
{
return $this->id;
}
/**
* @param mixed $id
*/
public function setId($id): void
{
$this->id = $id;
}
public function getTitle(): ?string
{
return $this->title;
}
public function setTitle(string $title): self
{
$this->title = $title;
return $this;
}
public function getType(): ?string
{
return $this->type;
}
public function setType(string $type): self
{
$this->type = $type;
return $this;
}
public function setConfig(?array $config): self
{
$this->config = $config;
return $this;
}
public function getIcon(): ?string
{
return $this->icon;
}
public function setIcon(?string $icon): self
{
$this->icon = $icon;
return $this;
}
public function getEntityFqcn(): ?string
{
return $this->entityFqcn;
}
public function setEntityFqcn(?string $entityFqcn): self
{
$this->entityFqcn = $entityFqcn;
return $this;
}
public function getRouteName(): ?string
{
return $this->routeName;
}
public function setRouteName($routeName): self
{
$this->routeName = $routeName;
return $this;
}
public function getUrl(): ?string
{
return $this->url;
}
public function setUrl(?string $url): self
{
$this->url = $url;
return $this;
}
public function getRoot()
{
return $this->root;
}
public function setParent($parent = null)
{
$this->parent = $parent;
}
public function getParent()
{
return $this->parent;
}
/**
* Get the value of entityId
*/
public function getEntityId()
{
return $this->entityId;
}
/**
* Set the value of entityId
*
* @return self
*/
public function setEntityId($entityId)
{
$this->entityId = $entityId;
return $this;
}
/**
* @return mixed
*/
public function getCssClass()
{
return strval($this->cssClass);
}
/**
* @param mixed $cssClass
*/
public function setCssClass($cssClass): void
{
$this->cssClass = $cssClass;
}
/**
* @return mixed
*/
public function getControllerFqcn()
{
return $this->controllerFqcn;
}
/**
* @param mixed $controllerFqcn
*/
public function setControllerFqcn($controllerFqcn): void
{
$this->controllerFqcn = $controllerFqcn;
}
/**
* @return mixed
*/
public function getControllerAction()
{
return $this->controllerAction;
}
/**
* @param mixed $controllerAction
*/
public function setControllerAction($controllerAction): void
{
$this->controllerAction = $controllerAction;
}
}