PHP Class Caffeinated\Menus\Builder

Afficher le fichier Open project: caffeinated/menus Class Usage Examples

Protected Properties

Свойство Type Description
$config array
$html Collective\Html\HtmlBuilder
$items array
$lastId integer
$name string
$reserved array
$url Illuminate\Routing\UrlGenerator

Méthodes publiques

Méthode Description
__call ( string $method, array $args ) : Item | boolean Dynamic search method against a menu attribute.
__construct ( string $name, array $config, HtmlBuilder $html, UrlGenerator $url ) Create a new Builder instance.
__get ( string $property ) : Item Returns menu item by name.
active ( ) : Caffeinated\Menus\Collection Fetches and returns all active state menu items.
add ( string $title, array | string $options = '' ) : Item Add an item to the defined menu.
all ( ) : Caffeinated\Menus\Collection Fetches and returns all menu items.
asUl ( array $attributes = [] ) : string Renders the menu as an unordered list.
attributes ( array $attributes = [] ) : string Converts the defined attributes into HTML.
config ( string $key ) : string Return the configuration value by key.
dispatch ( array $options ) : string Get the action type from the options.
divide ( array $attributes = [] ) : void Insert a divider after the item.
extractAttributes ( array $options = [] ) : array Extract the valid attributes from the passed options.
filter ( callable $callback ) : Builder Filter menu items through a callback.
filterRecursively ( string $attribute, mixed $value ) : Caffeinated\Menus\Collection Filter menu items recursively.
find ( integer $id ) : Item Fetches and returns a menu item by it's ID.
first ( ) : Item Fetches and returns the first menu item.
formatGroupClass ( $new, $old ) : mixed Format the groups class.
get ( string $slug ) : Item Fetches and returns a menu item by it's slug.
getLastGroupPrefix ( ) : mixed Get the prefix from the last group of the stack.
guard ( ) : Builder Filter menu items based on Shinobi permissions.
isAbsolute ( string $url ) : boolean Determines if the given URL is absolute.
item ( string $slug ) : Item Facade method for the get() method.
last ( ) : Item Fetches and returns the last menu item.
roots ( ) : Caffeinated\Menus\Collection Returns all items with no parents.
sortBy ( string $key ) : Builder Sorts the menu based on key given in ascending order.
sortByDesc ( string $key ) : Builder Sorts the menu based on key given in descending order.

Méthodes protégées

Méthode Description
getAction ( array | string $action ) : string Get the controller action for a "action" option.
getRoute ( array | string $route ) : string Get the route action for a "route" option.
getUrl ( array | string $options ) : string Get the action for a "url" option.
id ( ) : integer Generate a unique ID for every item added to the menu.
render ( string $type = 'ul', integer $parent = null ) : string Generate the menu items as list items, recursively.

Method Details

__call() public méthode

Dynamic search method against a menu attribute.
public __call ( string $method, array $args ) : Item | boolean
$method string
$args array
Résultat Item | boolean

__construct() public méthode

Create a new Builder instance.
public __construct ( string $name, array $config, HtmlBuilder $html, UrlGenerator $url )
$name string
$config array
$html Collective\Html\HtmlBuilder
$url Illuminate\Routing\UrlGenerator

__get() public méthode

Returns menu item by name.
public __get ( string $property ) : Item
$property string
Résultat Item

active() public méthode

Fetches and returns all active state menu items.
public active ( ) : Caffeinated\Menus\Collection
Résultat Caffeinated\Menus\Collection

add() public méthode

Add an item to the defined menu.
public add ( string $title, array | string $options = '' ) : Item
$title string
$options array | string
Résultat Item

all() public méthode

Fetches and returns all menu items.
public all ( ) : Caffeinated\Menus\Collection
Résultat Caffeinated\Menus\Collection

asUl() public méthode

Renders the menu as an unordered list.
public asUl ( array $attributes = [] ) : string
$attributes array
Résultat string

attributes() public méthode

Converts the defined attributes into HTML.
public attributes ( array $attributes = [] ) : string
$attributes array
Résultat string

config() public méthode

Return the configuration value by key.
public config ( string $key ) : string
$key string
Résultat string

dispatch() public méthode

Get the action type from the options.
public dispatch ( array $options ) : string
$options array
Résultat string

divide() public méthode

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

extractAttributes() public méthode

Extract the valid attributes from the passed options.
public extractAttributes ( array $options = [] ) : array
$options array
Résultat array

filter() public méthode

Since menu items are stored as a collection, this will simply forward the callback to the Laravel Collection filter() method and return the results.
public filter ( callable $callback ) : Builder
$callback callable
Résultat Builder

filterRecursively() public méthode

Filter menu items recursively.
public filterRecursively ( string $attribute, mixed $value ) : Caffeinated\Menus\Collection
$attribute string
$value mixed
Résultat Caffeinated\Menus\Collection

find() public méthode

Fetches and returns a menu item by it's ID.
public find ( integer $id ) : Item
$id integer
Résultat Item

first() public méthode

Fetches and returns the first menu item.
public first ( ) : Item
Résultat Item

formatGroupClass() public static méthode

Format the groups class.
public static formatGroupClass ( $new, $old ) : mixed
Résultat mixed

get() public méthode

Fetches and returns a menu item by it's slug.
public get ( string $slug ) : Item
$slug string
Résultat Item

getAction() protected méthode

Get the controller action for a "action" option.
protected getAction ( array | string $action ) : string
$action array | string
Résultat string

getLastGroupPrefix() public méthode

Get the prefix from the last group of the stack.
public getLastGroupPrefix ( ) : mixed
Résultat mixed

getRoute() protected méthode

Get the route action for a "route" option.
protected getRoute ( array | string $route ) : string
$route array | string
Résultat string

getUrl() protected méthode

Get the action for a "url" option.
protected getUrl ( array | string $options ) : string
$options array | string
Résultat string

guard() public méthode

Filter menu items based on Shinobi permissions.
public guard ( ) : Builder
Résultat Builder

id() protected méthode

Generate a unique ID for every item added to the menu.
protected id ( ) : integer
Résultat integer

isAbsolute() public static méthode

Determines if the given URL is absolute.
public static isAbsolute ( string $url ) : boolean
$url string
Résultat boolean

item() public méthode

Facade method for the get() method.
public item ( string $slug ) : Item
$slug string
Résultat Item

last() public méthode

Fetches and returns the last menu item.
public last ( ) : Item
Résultat Item

render() protected méthode

Generate the menu items as list items, recursively.
protected render ( string $type = 'ul', integer $parent = null ) : string
$type string
$parent integer
Résultat string

roots() public méthode

Returns all items with no parents.
public roots ( ) : Caffeinated\Menus\Collection
Résultat Caffeinated\Menus\Collection

sortBy() public méthode

Sorts the menu based on key given in ascending order.
public sortBy ( string $key ) : Builder
$key string
Résultat Builder

sortByDesc() public méthode

Sorts the menu based on key given in descending order.
public sortByDesc ( string $key ) : Builder
$key string
Résultat Builder

Property Details

$config protected_oe property

protected array $config
Résultat array

$html protected_oe property

protected HtmlBuilder,Collective\Html $html
Résultat Collective\Html\HtmlBuilder

$items protected_oe property

protected array $items
Résultat array

$lastId protected_oe property

protected int $lastId
Résultat integer

$name protected_oe property

protected string $name
Résultat string

$reserved protected_oe property

protected array $reserved
Résultat array

$url protected_oe property

protected UrlGenerator,Illuminate\Routing $url
Résultat Illuminate\Routing\UrlGenerator