<?php
namespace App\Entity\App;
use App\Model\App\MenuItem;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
/**
* Menu
*
* @ORM\Table(name="menu")
* @ORM\Entity(repositoryClass="App\Repository\App\MenuRepository")
* @ORM\Cache(usage="READ_ONLY", region="public")
*/
class Menu implements \Stringable
{
/**
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
*/
private int $id;
// #[ORM\Column(name: 'slug', type: 'string', length: 30, nullable: true)]
/**
* @ORM\Column(name="slug", type="string", length=30, nullable=true)
*/
private ?string $slug;
// #[ORM\Column(name: 'attributes', type: Types::JSON, nullable: true, options: ['jsonb' => true])]
/**
* @ORM\Column(name="attributes", type="json", nullable=true, options={"jsonb": true})
*/
private ?array $attributes;
// #[ORM\Column(name: 'title', type: 'string', length: 50)]
/**
* @ORM\Column(name="title", type="string", length=50)
*/
private ?string $title;
// #[ORM\Column(name: 'locale', type: 'string', length: 2, nullable: true)]
/**
* @ORM\Column(name="locale", type="string", length=2, nullable=true)
*/
private ?string $locale;
// #[ORM\Column(name: 'url', type: 'string', length: 255, nullable: true)]
/**
* @ORM\Column(name="url", type="string", length=255, nullable=true)
*/
private ?string $url;
// #[ORM\Column(name: 'path', type: 'string', length: 50, nullable: true)]
/**
* @ORM\Column(name="path", type="string", length=50, nullable=true)
*/
private ?string $path;
// #[ORM\Column(name: 'parameters', type: Types::JSON, nullable: true, options: ['jsonb' => true])]
/**
* @ORM\Column(name="parameters", type="json", nullable=true, options={"jsonb": true})
*/
private ?array $parameters;
// #[ORM\Column(name: 'widget', type: 'string', length: 100, nullable: true)]
/**
* @ORM\Column(name="widget", type="string", nullable=true)
*/
private ?string $widget;
// #[ORM\Column(name: 'item_order', type: 'integer', nullable: true)]
/**
* @ORM\Column(name="item_order", type="integer", nullable=true)
*/
private ?int $order = 0;
// #[ORM\Column(name: 'has_right', type: 'boolean')]
/**
* @ORM\Column(name="has_right", type="boolean")
*/
private bool $hasRight = true;
// #[ORM\Column(name: 'user_right', type: 'string', nullable: true)]
/**
* @ORM\Column(name="user_right", type="string", nullable=true)
*/
private ?string $right;
// #[ORM\OneToMany(mappedBy: 'menu', targetEntity: Menu::class, cascade: ['persist'], fetch: 'EAGER')]
// #[ORM\OrderBy(['order' => 'ASC'])]
/**
* @ORM\OneToMany(targetEntity="App\Entity\App\Menu", mappedBy="menu",cascade={"persist"}, fetch="EAGER")
* @ORM\OrderBy({"order" = "ASC"})
*/
private Collection $items;
// #[ORM\ManyToOne(targetEntity: Menu::class, inversedBy: 'items')]
// #[ORM\JoinColumn(name: 'menu', referencedColumnName: 'id', nullable: true)]
/**
* @ORM\ManyToOne(targetEntity="App\Entity\App\Menu", inversedBy="items")
* @ORM\JoinColumn(name="menu", referencedColumnName="id", nullable=true)
*/
private ?Menu $menu;
public function __construct()
{
$this->items = new ArrayCollection();
}
public function __toString(): string
{
return (string) $this->getTitle();
}
/**
* Get id
*
* @return int|null
*/
public function getId()
{
return $this->id;
}
/**
* Set slug
*
* @param string $slug
*/
public function setSlug($slug): Menu
{
$this->slug = $slug;
return $this;
}
/**
* Get slug
*
* @return string
*/
public function getSlug():? string
{
return (string) $this->slug;
}
/**
* Set attributes
*
* @param array $attributes
*/
public function setAttributes($attributes): Menu
{
$this->attributes = $attributes;
return $this;
}
/**
* Get attributes
*/
public function getAttributes(): array
{
return $this->attributes ?? [];
}
/**
* Set title
*
* @param string $title
*/
public function setTitle($title): Menu
{
$this->title = $title;
return $this;
}
/**
* Get title
*
* @return string
*/
public function getTitle():? string
{
return $this->title;
}
/**
* Set locale
*
* @param string $locale
*/
public function setLocale($locale): Menu
{
$this->locale = $locale;
return $this;
}
/**
* Get locale
*
* @return string
*/
public function getLocale():? string
{
return $this->locale;
}
/**
* Set url
*
* @param string $url
*/
public function setUrl($url): Menu
{
$this->url = $url;
return $this;
}
/**
* Get url
*
* @return string
*/
public function getUrl():? string
{
return $this->url;
}
/**
* Set path
*
* @param string $path
*/
public function setPath($path): Menu
{
$this->path = $path;
return $this;
}
/**
* Get path
*
* @return string
*/
public function getPath():? string
{
return $this->path;
}
/**
* Set parameters
*
* @param array $parameters
*/
public function setParameters($parameters): Menu
{
$this->parameters = $parameters;
return $this;
}
/**
* Get parameters
*
* @return array
*/
public function getParameters():? array
{
return $this->parameters;
}
/**
* Get parameters
*/
public function getParameterValue(): array
{
return (array) (\is_string($this->parameters) ? json_decode($this->parameters) : $this->parameters);
}
public function setParams(?string $params=null): Menu
{
$this->parameters = json_decode((string) $params);
return $this;
}
/**
* @return string
*/
public function getParams()
{
return json_encode($this->parameters);
}
/**
* Set order
*
* @param integer $order
*/
public function setOrder($order): Menu
{
$this->order = $order;
return $this;
}
/**
* Get order
*
* @return integer
*/
public function getOrder():? int
{
return $this->order;
}
/**
* Set hasRight
*
* @param boolean $hasRight
*/
public function setHasRight($hasRight): static
{
$this->hasRight = $hasRight;
return $this;
}
/**
* Get hasRight
*
* @return boolean
*/
public function getHasRight()
{
return $this->hasRight;
}
/**
* Set right
*
* @param string $right
*/
public function setRight($right): Menu
{
$this->right = $right;
return $this;
}
/**
* Get right
*
* @return string
*/
public function getRight()
{
return $this->right;
}
/**
* Add item
*
*
*/
public function addItem(Menu $item): Menu
{
$this->items[] = $item;
$item->setLocale($this->locale);
return $this;
}
/**
* Remove item
*/
public function removeItem(Menu $item): void
{
$this->items->removeElement($item);
}
/**
* Get items
*/
public function getItems(): Collection
{
return $this->items;
}
/**
* Set menu
*
*
*/
public function setMenu(Menu $menu = null): Menu
{
if (!$menu instanceof \App\Entity\App\Menu) {
return $this;
}
$this->menu = $menu->addItem($this);
return $this;
}
/**
* Get menu
*
* @return Menu|null
*/
public function getMenu()
{
return $this->menu;
}
/**
* Set widget
*
* @param string $widget
*/
public function setWidget($widget): Menu
{
$this->widget = $widget;
return $this;
}
/**
* Get widget
*
* @return string
*/
public function getWidget():? string
{
return $this->widget;
}
}