PHP Class Lavary\Menu\Item

Datei anzeigen Open project: lavary/laravel-menu Class Usage Examples

Public Properties

Property 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

Property 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

Public Methods

Method 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 method

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

__get() public method

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

activate() public method

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

active() public method

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

add() public method

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

all() public method

Returns all childeren of the item
public all ( ) : Lavary\Menu\Collection
return Lavary\Menu\Collection

append() public method

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

attr() public method

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

cascade_data() public method

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

checkActivationStatus() public method

Decide if the item should be active

children() public method

Returns childeren of the item
public children ( ) : Lavary\Menu\Collection
return Lavary\Menu\Collection

data() public method

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

divide() public method

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

group() public method

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

hasChildren() public method

Checks if the item has any children
public hasChildren ( ) : boolean
return boolean

hasProperty() public method

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

id() public method

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

nickname() public method

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

prepend() public method

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

raw() public method

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

url() public method

Generate URL for link
public url ( ) : string
return string

Property Details

$attributes public_oe property

Attributes of menu item
public array $attributes
return array

$builder protected_oe property

Reference to the menu builder
protected Lavary\Menu\Menu $builder
return Lavary\Menu\Menu

$data protected_oe property

Extra information attached to the menu item
protected array $data
return array

$divider public_oe property

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

$id protected_oe property

The ID of the menu item
protected int $id
return integer

$isActive public_oe property

Flag for active state
public bool $isActive
return boolean

$nickname public_oe property

Item's title in camelCase
public string $nickname
return string

$parent protected_oe property

Parent Id of the menu item
protected int $parent
return integer

$title public_oe property

Item's title
public string $title
return string