PHP Класс Creitive\Breadcrumbs\Breadcrumbs

Показать файл Открыть проект Примеры использования класса

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

Свойство Тип Описание
$breadcrumbs array The array which will store all of our breadcrumbs.
$breadcrumbsCssClasses array Classes applied to the main
    container element.
$divider string The divider symbol between the breadcrumbs. Uses a slash as a default, since that's the Twitter Bootstrap style.
$listElement The DOM-element that wraps the breadcrumbs. Set to ul by default.

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

Метод Описание
__construct ( array $breadcrumbs = [], array $cssClasses = [] ) The class constructor. Accepts an optional array of breadcrumbs, and an optional array of CSS classes to be applied to the container element.
__toString ( ) : string __toString magic method.
add ( string $name = '', string $href = '', boolean $hrefIsFullUrl = false ) Adds a crumb to the internal array.
addCrumb ( string $name = '', string $href = '', boolean $hrefIsFullUrl = false ) Adds a crumb to the internal array.
addCssClasses ( $cssClasses ) Adds more CSS classes which will be applied to the containing
    element. Can be passed a string or an array. If passed a string, separate CSS classes should be separated with spaces.
count ( ) : integer Gets the current amount of breadcrumbs
getBreadcrumbs ( ) : array Gets the currently configured breadcrumbs.
getBreadcrumbsCssClasses ( ) : array Gets the currently configured breadcrumbs CSS classes.
getDivider ( ) : string Gets the divider currently in use.
isEmpty ( ) : boolean Checks whether there are any breadcrumbs added yet.
isValidCrumb ( array $crumb ) : boolean Checks whether a crumb is valid, so that it can safely be added to the internal breadcrumbs array.
removeAll ( ) Removes all breadcrumbs.
removeCssClasses ( string | array $cssClasses ) Removes one or more CSS classes that have been set by other methods. This method won't fail if the passed class has not been set already.
render ( ) : string Renders the complete breadcrumbs into Twitter Bootstrap-compatible HTML.
setBreadcrumbs ( array $breadcrumbs ) Sets all the breadcrumbs. Useful for quickly configuring the instance.
setCssClasses ( string | array $cssClasses ) Sets the CSS classes to be applied to the containing
    element. Can be passed a string or an array. If passed a string, separate CSS classes should be separated with spaces.
setDivider ( string $divider ) Sets the divider which will be printed between the breadcrumbs.
setListElement ( string $element ) Set the containing list DOM element

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

Метод Описание
renderCrumb ( string $name, string $href, boolean $isLast = false, number $position = null ) : string Renders a single breadcrumb, Twitter Bootstrap-style.
renderCrumbs ( ) : string Renders the crumbs one by one, and returns them concatenated.

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

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

The class constructor. Accepts an optional array of breadcrumbs, and an optional array of CSS classes to be applied to the container element.
public __construct ( array $breadcrumbs = [], array $cssClasses = [] )
$breadcrumbs array
$cssClasses array

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

__toString magic method.
public __toString ( ) : string
Результат string

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

Alias for Breadcrumbs::addCrumb method.
public add ( string $name = '', string $href = '', boolean $hrefIsFullUrl = false )
$name string The name of this breadcrumb, which will be seen by the users.
$href string If this parameter begins with a forward slash, it will be treated as a full URL, and the `$hrefIsFullUrl` parameter will be forced to `true`, regardless of its value.
$hrefIsFullUrl boolean Whether the `$href` argument is a full URL or just a segment. The difference is that segments will be built upon previous breadcrumbs, while full URLs will be returned as they are inputted. This can be automatically forced to `true`, depending on the `$href` argument - read its description for details.

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

Adds a crumb to the internal array.
public addCrumb ( string $name = '', string $href = '', boolean $hrefIsFullUrl = false )
$name string The name of this breadcrumb, which will be seen by the users.
$href string If this parameter begins with a forward slash, it will be treated as a full URL, and the `$hrefIsFullUrl` parameter will be forced to `true`, regardless of its value.
$hrefIsFullUrl boolean Whether the `$href` argument is a full URL or just a segment. The difference is that segments will be built upon previous breadcrumbs, while full URLs will be returned as they are inputted. This can be automatically forced to `true`, depending on the `$href` argument - read its description for details.

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

Adds more CSS classes which will be applied to the containing
    element. Can be passed a string or an array. If passed a string, separate CSS classes should be separated with spaces.
public addCssClasses ( $cssClasses )

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

Gets the current amount of breadcrumbs
public count ( ) : integer
Результат integer

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

Gets the currently configured breadcrumbs.
public getBreadcrumbs ( ) : array
Результат array

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

Gets the currently configured breadcrumbs CSS classes.
public getBreadcrumbsCssClasses ( ) : array
Результат array

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

Gets the divider currently in use.
public getDivider ( ) : string
Результат string

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

Checks whether there are any breadcrumbs added yet.
public isEmpty ( ) : boolean
Результат boolean

isValidCrumb() публичный статический Метод

Checks whether a crumb is valid, so that it can safely be added to the internal breadcrumbs array.
public static isValidCrumb ( array $crumb ) : boolean
$crumb array
Результат boolean

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

Removes all breadcrumbs.
public removeAll ( )

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

Removes one or more CSS classes that have been set by other methods. This method won't fail if the passed class has not been set already.
public removeCssClasses ( string | array $cssClasses )
$cssClasses string | array

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

Renders the complete breadcrumbs into Twitter Bootstrap-compatible HTML.
public render ( ) : string
Результат string

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

Renders a single breadcrumb, Twitter Bootstrap-style.
protected renderCrumb ( string $name, string $href, boolean $isLast = false, number $position = null ) : string
$name string
$href string
$isLast boolean
$position number
Результат string

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

Renders the crumbs one by one, and returns them concatenated.
protected renderCrumbs ( ) : string
Результат string

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

Sets all the breadcrumbs. Useful for quickly configuring the instance.
public setBreadcrumbs ( array $breadcrumbs )
$breadcrumbs array

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

Sets the CSS classes to be applied to the containing
    element. Can be passed a string or an array. If passed a string, separate CSS classes should be separated with spaces.
public setCssClasses ( string | array $cssClasses )
$cssClasses string | array

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

If set to null, the divider won't be printed at all.
public setDivider ( string $divider )
$divider string

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

Set the containing list DOM element
public setListElement ( string $element )
$element string

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

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

The array which will store all of our breadcrumbs.
protected array $breadcrumbs
Результат array

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

Classes applied to the main
    container element.
protected array $breadcrumbsCssClasses
Результат array

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

The divider symbol between the breadcrumbs. Uses a slash as a default, since that's the Twitter Bootstrap style.
protected string $divider
Результат string

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

The DOM-element that wraps the breadcrumbs. Set to ul by default.
protected $listElement