PHP Трейт NestedCollection, vanilla

С версии: 2.3
Автор: Becky Van Bussel ([email protected])
Показать файл Открыть проект

Открытые свойства

Свойство Тип Описание
$activeCssClass The css class to add to active items and groups.
$dividerCssClassPrefix CSS prefix for a divider item.
$headerCssClassPrefix CSS prefix for a header item.
$items List of items to sort.
$linkCssClassPrefix CSS prefix for a link item.
$useCssPrefix Whether to use CSS prefixes on the generated CSS classes for the items.

Защищенные свойства (Protected)

Свойство Тип Описание
$allowedItemModifiers The item modifiers allowed to be passed in the modifiers array.

Открытые методы

Метод Описание
addDivider ( string $key = '', string $cssClass = '', array | integer $sort = [] ) : object Add a divider to the items array.
addDividerIf ( boolean | string | array $isAllowed = true, string $key = '', string $cssClass = '', array | integer $sort = [] ) : object Add a divider to the items array if it satisfies the $isAllowed condition.
addGroup ( string $text = '', string $key = '', string $cssClass = '', array | integer $sort = [], array $modifiers = [] ) : SortableModule Add a group to the items array.
addGroupIf ( boolean | string | array $isAllowed = true, string $text = '', string $key = '', string $cssClass = '', array | integer $sort = [], array $modifiers = [] ) : object Add a group to the items array if it satisfies the $isAllowed condition.
addItemModifiers ( array &$item, array $modifiers ) Adds the attributes in the modifiers array to the item.
addLink ( string $text, string $url, string $key = '', string $cssClass = '', array | integer $sort = [], array $modifiers = [], boolean $disabled = false ) Add a link to the items array.
addLinkIf ( boolean | string | array $isAllowed = true, string $text, string $url, string $key = '', string $cssClass = '', array | integer $sort = [], array $modifiers = [], boolean $disabled = false ) : object Add a link to the items array if it satisfies the $isAllowed condition.
getHighlightRoute ( ) : string
prepare ( ) : boolean Prepares the items array for output by sorting and optionally flattening.
removeItem ( string $key ) Remove an item from the nested set.
setForceDivider ( boolean $forceDivider )
setHighlightRoute ( string $highlightRoute )

Защищенные методы

Метод Описание
addItem ( string $type, array $item ) Add an item to the items array.
buildCssClass ( string $prefix, array $item ) : string Builds a CSS class for an item, based on the 'key' property of the item.
flattenArray ( array $items ) : array Creates a flattened array of menu items.
isActive ( array $item ) : boolean Checks whether the current request url matches an item's link url.
isAllowed ( boolean | string | array $isAllowed ) : boolean Checks whether an item can be added to the items list by returning it if it is already a boolean, or checking the permission if it is a string or array.
prepareData ( array &$items ) Performs post-sort operations to the items array.
sortItems ( array &$items ) Recursive function to sort the items in a given array.
sortItemsOrder ( array $item, array $items, integer $depth ) : number Get the sort order of an item in the items array.
touchKey ( array &$item ) Generate a key for an item if one does not exist, and add the property to the item.

Описание методов

addDivider() публичный Метод

Add a divider to the items array.
public addDivider ( string $key = '', string $cssClass = '', array | integer $sort = [] ) : object
$key string The item's key (for sorting and CSS targeting).
$cssClass string The divider's CSS class.
$sort array | integer Either a numeric sort position or and array in the style: array('before|after', 'key').
Результат object $this The calling object.

addDividerIf() публичный Метод

Add a divider to the items array if it satisfies the $isAllowed condition.
public addDividerIf ( boolean | string | array $isAllowed = true, string $key = '', string $cssClass = '', array | integer $sort = [] ) : object
$isAllowed boolean | string | array Either a boolean to indicate whether to actually add the item or a permission string or array of permission strings (full match) to check.
$key string The item's key (for sorting and CSS targeting).
$cssClass string The divider's CSS class.
$sort array | integer Either a numeric sort position or and array in the style: array('before|after', 'key').
Результат object $this The calling object.

addGroup() публичный Метод

Add a group to the items array.
public addGroup ( string $text = '', string $key = '', string $cssClass = '', array | integer $sort = [], array $modifiers = [] ) : SortableModule
$text string The display text for the group header.
$key string The item's key (for sorting and CSS targeting).
$cssClass string The group header's CSS class.
$sort array | integer Either a numeric sort position or and array in the style: array('before|after', 'key').
$modifiers array List of attribute => value, where the attribute is in $this->allowedItemModifiers. - **popinRel**: string - Endpoint for a popin. - **badge**: string - Info to put into a badge, usually a number. - **icon**: string - Name of the icon for the item, excluding the 'icon-' prefix.
Результат SortableModule $this The calling object.

addGroupIf() публичный Метод

Add a group to the items array if it satisfies the $isAllowed condition.
public addGroupIf ( boolean | string | array $isAllowed = true, string $text = '', string $key = '', string $cssClass = '', array | integer $sort = [], array $modifiers = [] ) : object
$isAllowed boolean | string | array Either a boolean to indicate whether to actually add the item or a permission string or array of permission strings (full match) to check.
$text string The display text for the group header.
$key string The item's key (for sorting and CSS targeting).
$cssClass string The group header's CSS class.
$sort array | integer Either a numeric sort position or and array in the style: array('before|after', 'key').
$modifiers array List of attribute => value, where the attribute is in $this->allowedItemModifiers. - **popinRel**: string - Endpoint for a popin. - **badge**: string - Info to put into a badge, usually a number. - **icon**: string - Name of the icon for the item, excluding the 'icon-' prefix.
Результат object $this The calling object.

addItem() защищенный Метод

Add an item to the items array.
protected addItem ( string $type, array $item )
$type string The type of the item: link, group or divider.
$item array The item to add to the array.

addItemModifiers() публичный Метод

Constrains the modifier to those defined in $this->allowedItemModifiers.
public addItemModifiers ( array &$item, array $modifiers )
$item array The item to modify.
$modifiers array The modifiers to add to the item.

addLinkIf() публичный Метод

Add a link to the items array if it satisfies the $isAllowed condition.
public addLinkIf ( boolean | string | array $isAllowed = true, string $text, string $url, string $key = '', string $cssClass = '', array | integer $sort = [], array $modifiers = [], boolean $disabled = false ) : object
$isAllowed boolean | string | array Either a boolean to indicate whether to actually add the item or a permission string or array of permission strings (full match) to check.
$text string The display text for the link.
$url string The destination url for the link.
$key string The item's key (for sorting and CSS targeting).
$cssClass string The link's CSS class.
$sort array | integer Either a numeric sort position or and array in the style: array('before|after', 'key').
$modifiers array List of attribute => value, where the attribute is in $this->allowedItemModifiers. - **popinRel**: string - Endpoint for a popin. - **badge**: string - Info to put into a badge, usually a number. - **icon**: string - Name of the icon for the item, excluding the 'icon-' prefix.
$disabled boolean Whether to disable the link.
Результат object $this The calling object.

buildCssClass() защищенный Метод

Optionally prepends a prefix to generated class names.
protected buildCssClass ( string $prefix, array $item ) : string
$prefix string The optional prefix to add to class name.
$item array The item to generate CSS class for.
Результат string The generated CSS class.

flattenArray() защищенный Метод

Useful for lists like dropdown menu, where nesting lists is not necessary.
protected flattenArray ( array $items ) : array
$items array The item list to flatten.
Результат array The flattened items list.

getHighlightRoute() публичный Метод

public getHighlightRoute ( ) : string
Результат string

isActive() защищенный Метод

Checks whether the current request url matches an item's link url.
protected isActive ( array $item ) : boolean
$item array The item to check.
Результат boolean Whether the current request url matches an item's link url.

isAllowed() защищенный Метод

Checks whether an item can be added to the items list by returning it if it is already a boolean, or checking the permission if it is a string or array.
protected isAllowed ( boolean | string | array $isAllowed ) : boolean
$isAllowed boolean | string | array Either a boolean to indicate whether to actually add the item or a permission string or array of permission strings (full match) to check.
Результат boolean Whether the item has permission to be added to the items list.

prepare() публичный Метод

Prepares the items array for output by sorting and optionally flattening.
public prepare ( ) : boolean
Результат boolean Whether to render the module.

prepareData() защищенный Метод

Removes empty groups, removes the '_sort' and 'key' attributes and bubbles up the active css class.
protected prepareData ( array &$items )
$items array The item list to parse.

removeItem() публичный Метод

Remove an item from the nested set.
public removeItem ( string $key )
$key string The key of the item to remove, separated by dots.

setForceDivider() публичный Метод

public setForceDivider ( boolean $forceDivider )
$forceDivider boolean Whether to separate groups with a
element. Only supported for flattened lists.

setHighlightRoute() публичный Метод

public setHighlightRoute ( string $highlightRoute )
$highlightRoute string

sortItems() защищенный Метод

Recursive function to sort the items in a given array.
protected sortItems ( array &$items )
$items array The items to sort.

sortItemsOrder() защищенный Метод

This function looks at the following keys: - **sort (numeric)**: A specific numeric sort was provided. - **sort array('before|after', 'key')**: You can specify that the item is before or after another item. - **_sort**: The order the item was added is used.
protected sortItemsOrder ( array $item, array $items, integer $depth ) : number
$item array The item to get the sort order from.
$items array The entire list of items.
$depth integer The current recursive depth used to prevent infinite recursion.
Результат number

touchKey() защищенный Метод

Generate a key for an item if one does not exist, and add the property to the item.
protected touchKey ( array &$item )
$item array The item to generate and add a key for.

Описание свойств

$activeCssClass публичное свойство

The css class to add to active items and groups.
public $activeCssClass

$allowedItemModifiers защищенное свойство

The item modifiers allowed to be passed in the modifiers array.
protected $allowedItemModifiers

$dividerCssClassPrefix публичное свойство

CSS prefix for a divider item.
public $dividerCssClassPrefix

$headerCssClassPrefix публичное свойство

CSS prefix for a header item.
public $headerCssClassPrefix

$items публичное свойство

List of items to sort.
public $items

$linkCssClassPrefix публичное свойство

CSS prefix for a link item.
public $linkCssClassPrefix

$useCssPrefix публичное свойство

Whether to use CSS prefixes on the generated CSS classes for the items.
public $useCssPrefix