Item
in package
implements
JsonSerializable
Represents an item in a menu.
Table of Contents
Interfaces
- JsonSerializable
Properties
Methods
- __construct() : mixed
- Constructor for creating a new menu item.
- __get() : mixed|null
- Magic method to get properties dynamically.
- Add() : Item
- Adds an item or items to this item.
- Create() : self
- Creates a new menu item.
- FromArray() : self
- Creates a menu item from an array.
- jsonSerialize() : object|array<string|int, mixed>
- Serializes the item to JSON.
- Merge() : void
- Merges the given items with this item.
- Route() : string
- Generates the route for the item.
- ToArray() : array<string|int, mixed>|object
- Converts the item to an array.
- _find() : self|null
- Internal method to find an item by name.
Properties
$parent
public
Item|null
$parent
= null
$_data
private
object|null
$_data
= null
Methods
__construct()
Constructor for creating a new menu item.
public
__construct(string $name, string $title, string $description[, string $icon = '' ][, string $execute = '' ]) : mixed
Parameters
- $name : string
-
The name of the item.
- $title : string
-
The title of the item.
- $description : string
-
The description of the item.
- $icon : string = ''
-
The icon associated with the item.
- $execute : string = ''
-
The action to execute when the item is clicked.
__get()
Magic method to get properties dynamically.
public
__get(string $name) : mixed|null
Parameters
- $name : string
-
The name of the property.
Return values
mixed|null —The value of the property or null if not found.
Add()
Adds an item or items to this item.
public
Add(Item|array<string|int, mixed> $item) : Item
Parameters
- $item : Item|array<string|int, mixed>
-
The item or items to add.
Return values
Item —This item.
Create()
Creates a new menu item.
public
static Create(string $name, string $title, string $description[, string $icon = '' ][, string $execute = '' ]) : self
Parameters
- $name : string
-
The name of the item.
- $title : string
-
The title of the item.
- $description : string
-
The description of the item.
- $icon : string = ''
-
The icon associated with the item.
- $execute : string = ''
-
The action to execute when the item is clicked.
Return values
self —The newly created menu item.
FromArray()
Creates a menu item from an array.
public
static FromArray(array<string|int, mixed> $array) : self
Parameters
- $array : array<string|int, mixed>
-
The array containing item data.
Return values
self —The newly created menu item.
jsonSerialize()
Serializes the item to JSON.
public
jsonSerialize() : object|array<string|int, mixed>
Return values
object|array<string|int, mixed> —The serialized item.
Merge()
Merges the given items with this item.
public
Merge(array<string|int, mixed> $items) : void
Parameters
- $items : array<string|int, mixed>
-
The items to merge.
Route()
Generates the route for the item.
public
Route() : string
Return values
string —The route of the item.
ToArray()
Converts the item to an array.
public
ToArray() : array<string|int, mixed>|object
Return values
array<string|int, mixed>|object —The converted item.
_find()
Internal method to find an item by name.
private
_find(string $name) : self|null
Parameters
- $name : string
-
The name of the item to find.
Return values
self|null —The found item or null if not found.