MenuItem
extends BaseEntity
in package
implements
ScopedTreeNodeInterface, IdentifiableInterface
uses
IdentifiableTrait, TranslationCollectionTrait
A menu item is a nested-set tree (lft/rgt/level + parentId); several roots live in one table, told apart by `menuId`. {@see ScopedTreeNodeInterface} is the gate by which the generic `save()` ({@see \App\Core\Traits\Api\Models\Managers\SaveTrait}) recognizes that a newly inserted item needs lft/rgt/level computed (`insertTreeNode`), and it supplies the scope (`menuId`) via {@see getTreeScope()}, so indexes are computed within one menu only, without overriding `treeConfigForEntity()` in the manager.
Tags
Attributes
- #[MappedSuperclass]
- #[TableAlias]
- $alias: 'menuItem'
Table of Contents
Interfaces
- ScopedTreeNodeInterface
- Nested-set tree where one table holds several independent trees distinguished by a scope column (e.g. menu items distinguished by `menuId`). Extends {@see TreeNodeInterface} with a scope that the entity knows about itself.
- IdentifiableInterface
- Entity with a simple integer primary key. Most entities have one (often via {@see \App\Core\Traits\Shared\Models\Entities\IdentifiableTrait}); texts and links with a composite key do not, which is why `getId()` is not on {@see \App\Core\Base\BaseEntity}. Code that needs the id of a generic entity asks for this interface (parameter type, template bound, `instanceof`).
Properties
- $active : bool
- $attributeId : string|null
- $blank : bool
- $class : string|null
- $extension : string|null
- $forLogged : bool
- $forUnlogged : bool
- $iconClass : string|null
- $id : int|null
- $level : int
- $lft : int
- $link : string|null
- $menuId : int
- $page : TPage|null
- $pageId : int|null
- $parameters : string|null
- $parentId : int|null
- $rgt : int
- $translations : Collection<int, TTranslation>
Methods
- __construct() : mixed
- addTranslation() : $this
- callInitMethods() : void
- Calls `init{TraitName}()` for every used trait that defines such a method.
- getActive() : bool
- getAllTraits() : array<string, string>
- Returns all traits the class uses, including those used by parent classes and nested traits.
- getAttributeClass() : string|null
- getAttributeId() : string|null
- getBlank() : bool
- getClass() : string|null
- getExtension() : string|null
- getForLogged() : bool
- getForUnlogged() : bool
- getIconClass() : string|null
- getId() : int|null
- getLevel() : int
- getLft() : int
- getLink() : string|null
- getMenuId() : int
- getPage() : TPage|null
- getPageId() : int|null
- getParameters() : string|null
- getParentId() : int|null
- getRgt() : int
- getTranslation() : TTranslation|null
- getTranslations() : Collection<int, TTranslation>
- getTreeScope() : array<string, scalar|null>
- Nested-set tree scope: items are numbered separately per menu.
- isActive() : bool
- isBlank() : bool
- isForLogged() : bool
- isForUnlogged() : bool
- isPersisted() : bool
- removeTranslation() : $this
- setActive() : $this
- setAttributeClass() : self
- setAttributeId() : $this
- setBlank() : $this
- setClass() : $this
- setExtension() : $this
- setForLogged() : $this
- setForUnlogged() : $this
- setIconClass() : $this
- setId() : $this
- setLevel() : $this
- setLft() : $this
- setLink() : $this
- setMenuId() : $this
- setPage() : $this
- setPageId() : $this
- setParameters() : $this
- setParentId() : $this
- setRgt() : $this
- setTranslations() : $this
- translationCollectionInit() : void
- getTraitsRecursive() : array<string, string>
- Walks the trait list recursively and collects nested traits too.
Properties
$active
protected
bool
$active
= true
Attributes
- #[Column]
- $name: 'active'
- $type: 'boolean'
$attributeId
protected
string|null
$attributeId
= null
Attributes
- #[Column]
- $name: 'id'
- $type: 'string'
- $length: 45
- $nullable: true
$blank
protected
bool
$blank
= false
Attributes
- #[Column]
- $name: 'blank'
- $type: 'boolean'
$class
protected
string|null
$class
= null
Attributes
- #[Column]
- $name: 'class'
- $type: 'string'
- $length: 45
- $nullable: true
$extension
protected
string|null
$extension
= null
Attributes
- #[Column]
- $name: 'extension'
- $type: 'string'
- $length: 255
- $nullable: true
$forLogged
protected
bool
$forLogged
= true
Attributes
- #[Column]
- $name: 'for_logged'
- $type: 'boolean'
$forUnlogged
protected
bool
$forUnlogged
= true
Attributes
- #[Column]
- $name: 'for_unlogged'
- $type: 'boolean'
$iconClass
protected
string|null
$iconClass
= null
Attributes
- #[Column]
- $name: 'icon_class'
- $type: 'string'
- $length: 50
- $nullable: true
$id
protected
int|null
$id
= null
Attributes
- #[Column]
- $name: 'menu_item_id'
- $type: 'integer'
- $options: ['unsigned' => true]
- #[GeneratedValue]
- #[Id]
$level
protected
int
$level
= 0
Attributes
- #[Column]
- $name: 'level'
- $type: 'integer'
- $options: ['unsigned' => true]
$lft
protected
int
$lft
= 0
Attributes
- #[Column]
- $name: 'lft'
- $type: 'integer'
- $options: ['unsigned' => true]
$link
protected
string|null
$link
= null
Attributes
- #[Column]
- $name: 'link'
- $type: 'string'
- $length: 255
- $nullable: true
$menuId
protected
int
$menuId
= 0
Attributes
- #[Column]
- $name: 'cms_system_menu_menu_id'
- $type: 'integer'
- $options: ['unsigned' => true]
$page
protected
TPage|null
$page
= null
$pageId
protected
int|null
$pageId
= null
Attributes
- #[Column]
- $name: 'cms_system_pages_page_id'
- $type: 'integer'
- $nullable: true
- $options: ['unsigned' => true]
$parameters
protected
string|null
$parameters
= null
Attributes
- #[Column]
- $name: 'parameters'
- $type: 'string'
- $length: 255
- $nullable: true
$parentId
protected
int|null
$parentId
= null
Attributes
- #[Column]
- $name: 'parent_id'
- $type: 'integer'
- $nullable: true
- $options: ['unsigned' => true]
$rgt
protected
int
$rgt
= 0
Attributes
- #[Column]
- $name: 'rgt'
- $type: 'integer'
- $options: ['unsigned' => true]
$translations
protected
Collection<int, TTranslation>
$translations
= new ArrayCollection()
Methods
__construct()
public
__construct([int|null $id = null ][, int|null $pageId = null ][, mixed $page = null ][, int $menuId = 0 ][, int|null $parentId = null ][, int $lft = 0 ][, int $rgt = 0 ][, int $level = 0 ][, string|null $class = null ][, string|null $iconClass = null ][, string|null $attributeId = null ][, string|null $link = null ][, string|null $extension = null ][, string|null $parameters = null ][, bool $active = true ][, bool $blank = false ][, bool $forLogged = true ][, bool $forUnlogged = true ][, Collection $translations = new ArrayCollection() ]) : mixed
Parameters
- $id : int|null = null
- $pageId : int|null = null
- $page : mixed = null
- $menuId : int = 0
- $parentId : int|null = null
- $lft : int = 0
- $rgt : int = 0
- $level : int = 0
- $class : string|null = null
- $iconClass : string|null = null
- $attributeId : string|null = null
- $link : string|null = null
- $extension : string|null = null
- $parameters : string|null = null
- $active : bool = true
- $blank : bool = false
- $forLogged : bool = true
- $forUnlogged : bool = true
- $translations : Collection = new ArrayCollection()
addTranslation()
public
addTranslation(TTranslation $translation) : $this
Parameters
- $translation : TTranslation
Return values
$thiscallInitMethods()
Calls `init{TraitName}()` for every used trait that defines such a method.
public
callInitMethods() : void
getActive()
public
getActive() : bool
Return values
boolgetAllTraits()
Returns all traits the class uses, including those used by parent classes and nested traits.
public
getAllTraits() : array<string, string>
Return values
array<string, string>getAttributeClass()
public
getAttributeClass() : string|null
Return values
string|nullgetAttributeId()
public
getAttributeId() : string|null
Return values
string|nullgetBlank()
public
getBlank() : bool
Return values
boolgetClass()
public
getClass() : string|null
Return values
string|nullgetExtension()
public
getExtension() : string|null
Return values
string|nullgetForLogged()
public
getForLogged() : bool
Return values
boolgetForUnlogged()
public
getForUnlogged() : bool
Return values
boolgetIconClass()
public
getIconClass() : string|null
Return values
string|nullgetId()
public
getId() : int|null
Return values
int|nullgetLevel()
public
getLevel() : int
Return values
intgetLft()
public
getLft() : int
Return values
intgetLink()
public
getLink() : string|null
Return values
string|nullgetMenuId()
public
getMenuId() : int
Return values
intgetPage()
public
getPage() : TPage|null
Return values
TPage|nullgetPageId()
public
getPageId() : int|null
Return values
int|nullgetParameters()
public
getParameters() : string|null
Return values
string|nullgetParentId()
public
getParentId() : int|null
Return values
int|nullgetRgt()
public
getRgt() : int
Return values
intgetTranslation()
public
getTranslation(int $langId) : TTranslation|null
Parameters
- $langId : int
Return values
TTranslation|nullgetTranslations()
public
getTranslations() : Collection<int, TTranslation>
Return values
Collection<int, TTranslation>getTreeScope()
Nested-set tree scope: items are numbered separately per menu.
public
getTreeScope() : array<string, scalar|null>
Return values
array<string, scalar|null>isActive()
public
isActive() : bool
Return values
boolisBlank()
public
isBlank() : bool
Return values
boolisForLogged()
public
isForLogged() : bool
Return values
boolisForUnlogged()
public
isForUnlogged() : bool
Return values
boolisPersisted()
public
isPersisted() : bool
Return values
boolremoveTranslation()
public
removeTranslation(TTranslation $translation) : $this
Parameters
- $translation : TTranslation
Return values
$thissetActive()
public
setActive(bool $active) : $this
Parameters
- $active : bool
Return values
$thissetAttributeClass()
public
setAttributeClass(string|null $class) : self
Parameters
- $class : string|null
Return values
selfsetAttributeId()
public
setAttributeId(string|null $attributeId) : $this
Parameters
- $attributeId : string|null
Return values
$thissetBlank()
public
setBlank(bool $blank) : $this
Parameters
- $blank : bool
Return values
$thissetClass()
public
setClass(string|null $class) : $this
Parameters
- $class : string|null
Return values
$thissetExtension()
public
setExtension(string|null $extension) : $this
Parameters
- $extension : string|null
Return values
$thissetForLogged()
public
setForLogged(bool $forLogged) : $this
Parameters
- $forLogged : bool
Return values
$thissetForUnlogged()
public
setForUnlogged(bool $forUnlogged) : $this
Parameters
- $forUnlogged : bool
Return values
$thissetIconClass()
public
setIconClass(string|null $iconClass) : $this
Parameters
- $iconClass : string|null
Return values
$thissetId()
public
setId(int|null $id) : $this
Parameters
- $id : int|null
Return values
$thissetLevel()
public
setLevel(int $level) : $this
Parameters
- $level : int
Return values
$thissetLft()
public
setLft(int $lft) : $this
Parameters
- $lft : int
Return values
$thissetLink()
public
setLink(string|null $link) : $this
Parameters
- $link : string|null
Return values
$thissetMenuId()
public
setMenuId(int $menuId) : $this
Parameters
- $menuId : int
Return values
$thissetPage()
public
setPage(TPage|null $page) : $this
Parameters
- $page : TPage|null
Return values
$thissetPageId()
public
setPageId(int|null $pageId) : $this
Parameters
- $pageId : int|null
Return values
$thissetParameters()
public
setParameters(string|null $parameters) : $this
Parameters
- $parameters : string|null
Return values
$thissetParentId()
public
setParentId(int|null $parentId) : $this
Parameters
- $parentId : int|null
Return values
$thissetRgt()
public
setRgt(int $rgt) : $this
Parameters
- $rgt : int
Return values
$thissetTranslations()
public
setTranslations(Collection<int, TTranslation>|array<int, TTranslation> $translations) : $this
Parameters
- $translations : Collection<int, TTranslation>|array<int, TTranslation>
Return values
$thistranslationCollectionInit()
public
translationCollectionInit() : void
getTraitsRecursive()
Walks the trait list recursively and collects nested traits too.
private
static getTraitsRecursive(array<string, string> $traits) : array<string, string>
Parameters
- $traits : array<string, string>