class BreadcrumbManager implements ChainBreadcrumbBuilderInterface (View source)

Provides a breadcrumb manager.

Can be assigned any number of BreadcrumbBuilderInterface objects by calling the addBuilder() method. When build() is called it iterates over the objects in priority order and uses the first one that returns TRUE from BreadcrumbBuilderInterface::applies() to build the breadcrumbs.

Properties

protected ModuleHandlerInterface $moduleHandler

The module handler to invoke the alter hook.

protected array $builders

Holds arrays of breadcrumb builders, keyed by priority.

protected BreadcrumbBuilderInterface[]|null $sortedBuilders

Holds the array of breadcrumb builders sorted by priority.

Methods

__construct(ModuleHandlerInterface $module_handler)

Constructs a \Drupal\Core\Breadcrumb\BreadcrumbManager object.

addBuilder(BreadcrumbBuilderInterface $builder, int $priority)

Adds another breadcrumb builder.

bool
applies(RouteMatchInterface $route_match)

Whether this breadcrumb builder should be used to build the breadcrumb.

build(RouteMatchInterface $route_match)

Builds the breadcrumb.

getSortedBuilders()

Returns the sorted array of breadcrumb builders.

Details

__construct(ModuleHandlerInterface $module_handler)

Constructs a \Drupal\Core\Breadcrumb\BreadcrumbManager object.

Parameters

ModuleHandlerInterface $module_handler

The module handler.

addBuilder(BreadcrumbBuilderInterface $builder, int $priority)

Adds another breadcrumb builder.

Parameters

BreadcrumbBuilderInterface $builder

The breadcrumb builder to add.

int $priority

Priority of the breadcrumb builder.

bool applies(RouteMatchInterface $route_match)

Whether this breadcrumb builder should be used to build the breadcrumb.

Parameters

RouteMatchInterface $route_match

The current route match.

Return Value

bool

TRUE if this builder should be used or FALSE to let other builders decide.

Breadcrumb build(RouteMatchInterface $route_match)

Builds the breadcrumb.

Parameters

RouteMatchInterface $route_match

The current route match.

Return Value

Breadcrumb

A breadcrumb.

protected BreadcrumbBuilderInterface[] getSortedBuilders()

Returns the sorted array of breadcrumb builders.

Return Value

BreadcrumbBuilderInterface[]

An array of breadcrumb builder objects.