\Menu\ViewBreadcrumbRegistry

BreadcrumbRegistry class.

Breadcrumb indicate the current page's location within a navigational hierarchy. This class is used as a registry and provides several methods for manage the crumbs stack.

Summary

Methods
Properties
Constants
push()
pop()
clear()
count()
getStack()
getUrls()
No public properties found
No constants found
No protected methods found
$_crumbs
N/A
No private methods found
No private properties found
N/A

Properties

$_crumbs

$_crumbs : array

Crumbs stack.

Type

array

Methods

push()

push(array|string $crumbs, mixed $url) : boolean

Adds a new crumb to the stack.

Usage

Single crumb push as an array:

BreadcrumbRegistry::push(['title' => 'Crumb 1', 'url' => 'URL for crumb 1']);
BreadcrumbRegistry::push(['title' => 'Crumb 2', 'url' => '/MyPlugin/my_controller/action_name']);
BreadcrumbRegistry::push(['title' => 'Crumb 3', 'url' => 'URL for crumb 3']);

Multiple crumbs at once:

BreadcrumbRegistry::push([
    ['title' => 'Crumb 1', 'url' => 'URL for crumb 1'],
    ['title' => 'Crumb 2', 'url' => '/MyPlugin/my_controller/action_name'],
    ['title' => 'Crumb 3', 'url' => 'URL for crumb 3'],
]);

"title" and "URL" as arguments:

BreadcrumbRegistry::push('Crumb 1', 'URL for crumb 1');
BreadcrumbRegistry::push('Crumb 2', ['plugin' => 'MyPlugin', 'controller' => 'my_controller', 'action' => 'action_name']);
BreadcrumbRegistry::push('Crumb 3', 'URL for crumb 3');

All three examples above produces the same HTML output when using BreadcrumbHelper::render():

<ol>
    <li class="first-item"><a href="URL for crumb 1"><span>Crumb 1</span></a></li>
    <li class="active"><a href="/MyPlugin/my_controller/action_name"><span>Crumb 2</span></a></li>
    <li class="last-item"><a href="URL for crumb 3"><span>Crumb 3</span></a></li>
</ol>

NOTE: you can provide URLs as both, string values or as an array compatible with Router::url().

Parameters

array|string $crumbs

Single crumb or an array of multiple crumbs to push at once

mixed $url

If both $crumbs is a string value and $url is a string (or an array) value they will be used as title and url respectively

Returns

boolean —

True on success, False otherwise

pop()

pop() : array

Pops and returns the last crumb of the crumbs stack.

Returns

array

clear()

clear() : void

Clears the crumbs stack.

count()

count() : integer

Counts the number of crumbs in the stack.

Returns

integer

getStack()

getStack() : array

Gets the full array stack of crumbs.

Returns

array

getUrls()

getUrls() : array

Gets a list of all URLs.

Returns

array