class Breadcrumb
Same name in other branches
- 9 core/lib/Drupal/Core/Breadcrumb/Breadcrumb.php \Drupal\Core\Breadcrumb\Breadcrumb
- 8.9.x core/lib/Drupal/Core/Breadcrumb/Breadcrumb.php \Drupal\Core\Breadcrumb\Breadcrumb
- 10 core/lib/Drupal/Core/Breadcrumb/Breadcrumb.php \Drupal\Core\Breadcrumb\Breadcrumb
Used to return generated breadcrumbs with associated cacheability metadata.
Hierarchy
- class \Drupal\Core\Breadcrumb\Breadcrumb implements \Drupal\Core\Render\RenderableInterface, \Drupal\Core\Cache\RefinableCacheableDependencyInterface uses \Drupal\Core\Cache\RefinableCacheableDependencyTrait
Expanded class hierarchy of Breadcrumb
12 files declare their use of Breadcrumb
- BookBreadcrumbBuilder.php in core/
modules/ book/ src/ BookBreadcrumbBuilder.php - BreadcrumbManagerTest.php in core/
tests/ Drupal/ Tests/ Core/ Breadcrumb/ BreadcrumbManagerTest.php - BreadcrumbTest.php in core/
tests/ Drupal/ Tests/ Core/ Breadcrumb/ BreadcrumbTest.php - CommentBreadcrumbBuilder.php in core/
modules/ comment/ src/ CommentBreadcrumbBuilder.php - ForumBreadcrumbBuilderBase.php in core/
modules/ forum/ src/ Breadcrumb/ ForumBreadcrumbBuilderBase.php
10 string references to 'Breadcrumb'
- block.block.claro_breadcrumbs.yml in core/
themes/ claro/ config/ optional/ block.block.claro_breadcrumbs.yml - core/themes/claro/config/optional/block.block.claro_breadcrumbs.yml
- block.block.olivero_breadcrumbs.yml in core/
themes/ olivero/ config/ optional/ block.block.olivero_breadcrumbs.yml - core/themes/olivero/config/optional/block.block.olivero_breadcrumbs.yml
- Breadcrumb404Test::testBreadcrumbOn404Pages in core/
tests/ Drupal/ FunctionalTests/ Breadcrumb/ Breadcrumb404Test.php - Tests that different 404s don't create unnecessary cache entries.
- claro.info.yml in core/
themes/ claro/ claro.info.yml - core/themes/claro/claro.info.yml
- d7_block.yml in core/
modules/ block/ migrations/ d7_block.yml - core/modules/block/migrations/d7_block.yml
File
-
core/
lib/ Drupal/ Core/ Breadcrumb/ Breadcrumb.php, line 13
Namespace
Drupal\Core\BreadcrumbView source
class Breadcrumb implements RenderableInterface, RefinableCacheableDependencyInterface {
use RefinableCacheableDependencyTrait;
/**
* An ordered list of links for the breadcrumb.
*
* @var \Drupal\Core\Link[]
*/
protected $links = [];
/**
* Gets the breadcrumb links.
*
* @return \Drupal\Core\Link[]
*/
public function getLinks() {
return $this->links;
}
/**
* Sets the breadcrumb links.
*
* @param \Drupal\Core\Link[] $links
* The breadcrumb links.
*
* @return $this
*
* @throws \LogicException
* Thrown when setting breadcrumb links after they've already been set.
*/
public function setLinks(array $links) {
if (!empty($this->links)) {
throw new \LogicException('Once breadcrumb links are set, only additional breadcrumb links can be added.');
}
$this->links = $links;
return $this;
}
/**
* Appends a link to the end of the ordered list of breadcrumb links.
*
* @param \Drupal\Core\Link $link
* The link appended to the breadcrumb.
*
* @return $this
*/
public function addLink(Link $link) {
$this->links[] = $link;
return $this;
}
/**
* {@inheritdoc}
*/
public function toRenderable() {
$build = [
'#cache' => [
'contexts' => $this->cacheContexts,
'tags' => $this->cacheTags,
'max-age' => $this->cacheMaxAge,
],
];
if (!empty($this->links)) {
$build += [
'#theme' => 'breadcrumb',
'#links' => $this->links,
];
}
return $build;
}
}
Members
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.