PHP Class Lavary\Menu\Item

Afficher le fichier Open project: lavary/laravel-menu Class Usage Examples

Méthodes publiques

Свойство Type Description
$attributes array Attributes of menu item
$divider array Item's seprator from the rest of the items, if it has any.
$isActive boolean Flag for active state
$nickname string Item's title in camelCase
$title string Item's title

Protected Properties

Свойство Type Description
$builder Lavary\Menu\Menu Reference to the menu builder
$data array Extra information attached to the menu item
$id integer The ID of the menu item
$parent integer Parent Id of the menu item

Méthodes publiques

Méthode Description
__construct ( Menu $builder, $id, string $title, $options ) : void Creates a new Lavary\Menu\MenuItem instance.
__get ( $prop ) : string Search in meta data if a property doesn't exist otherwise return the property
activate ( Item $item = null ) Activat the item
active ( $pattern = null ) : Lavary\Menu\Item Make the item active
add ( string $title, string | array $options = '' ) : void Creates a sub Item
all ( ) : Lavary\Menu\Collection Returns all childeren of the item
append ( $html ) : Lavary\Menu\Item Appends text or html to the item
attr ( ) : string | Lavary\Menu\Item Add attributes to the item
cascade_data ( array $args = [] ) Cascade data to children
checkActivationStatus ( ) Decide if the item should be active
children ( ) : Lavary\Menu\Collection Returns childeren of the item
data ( ) : string | Lavary\Menu\Item Set or get items's meta data
divide ( array $attributes = [] ) : void Insert a seprator after the item
group ( array $attributes, callable $closure ) : void Group children of the item
hasChildren ( ) : boolean Checks if the item has any children
hasProperty ( String $property ) : boolean Check if propery exists either in the class or the meta collection
id ( mixed $id = null ) : /Lavary/Menu/Item Set id for the item manually
nickname ( string $nickname = null ) : /Lavary/Menu/Item Set nickname for the item manually
prepend ( $html ) : Lavary\Menu\Item Prepends text or html to the item
raw ( $title, array $options = [] ) : Lavary\Menu\Item Add a plain text item
url ( ) : string Generate URL for link

Method Details

__construct() public méthode

Creates a new Lavary\Menu\MenuItem instance.
public __construct ( Menu $builder, $id, string $title, $options ) : void
$builder Menu
$title string
Résultat void

__get() public méthode

Search in meta data if a property doesn't exist otherwise return the property
public __get ( $prop ) : string
Résultat string

activate() public méthode

Activat the item
public activate ( Item $item = null )
$item Item

active() public méthode

Make the item active
public active ( $pattern = null ) : Lavary\Menu\Item
Résultat Lavary\Menu\Item

add() public méthode

Creates a sub Item
public add ( string $title, string | array $options = '' ) : void
$title string
$options string | array
Résultat void

all() public méthode

Returns all childeren of the item
public all ( ) : Lavary\Menu\Collection
Résultat Lavary\Menu\Collection

append() public méthode

Appends text or html to the item
public append ( $html ) : Lavary\Menu\Item
Résultat Lavary\Menu\Item

attr() public méthode

Add attributes to the item
public attr ( ) : string | Lavary\Menu\Item
Résultat string | Lavary\Menu\Item

cascade_data() public méthode

Cascade data to children
public cascade_data ( array $args = [] )
$args array

checkActivationStatus() public méthode

Decide if the item should be active

children() public méthode

Returns childeren of the item
public children ( ) : Lavary\Menu\Collection
Résultat Lavary\Menu\Collection

data() public méthode

Set or get items's meta data
public data ( ) : string | Lavary\Menu\Item
Résultat string | Lavary\Menu\Item

divide() public méthode

Insert a seprator after the item
public divide ( array $attributes = [] ) : void
$attributes array
Résultat void

group() public méthode

Group children of the item
public group ( array $attributes, callable $closure ) : void
$attributes array
$closure callable
Résultat void

hasChildren() public méthode

Checks if the item has any children
public hasChildren ( ) : boolean
Résultat boolean

hasProperty() public méthode

Check if propery exists either in the class or the meta collection
public hasProperty ( String $property ) : boolean
$property String
Résultat boolean

id() public méthode

Set id for the item manually
public id ( mixed $id = null ) : /Lavary/Menu/Item
$id mixed
Résultat /Lavary/Menu/Item

nickname() public méthode

Set nickname for the item manually
public nickname ( string $nickname = null ) : /Lavary/Menu/Item
$nickname string
Résultat /Lavary/Menu/Item

prepend() public méthode

Prepends text or html to the item
public prepend ( $html ) : Lavary\Menu\Item
Résultat Lavary\Menu\Item

raw() public méthode

Add a plain text item
public raw ( $title, array $options = [] ) : Lavary\Menu\Item
$options array
Résultat Lavary\Menu\Item

url() public méthode

Generate URL for link
public url ( ) : string
Résultat string

Property Details

$attributes public_oe property

Attributes of menu item
public array $attributes
Résultat array

$builder protected_oe property

Reference to the menu builder
protected Lavary\Menu\Menu $builder
Résultat Lavary\Menu\Menu

$data protected_oe property

Extra information attached to the menu item
protected array $data
Résultat array

$divider public_oe property

Item's seprator from the rest of the items, if it has any.
public array $divider
Résultat array

$id protected_oe property

The ID of the menu item
protected int $id
Résultat integer

$isActive public_oe property

Flag for active state
public bool $isActive
Résultat boolean

$nickname public_oe property

Item's title in camelCase
public string $nickname
Résultat string

$parent protected_oe property

Parent Id of the menu item
protected int $parent
Résultat integer

$title public_oe property

Item's title
public string $title
Résultat string