class Breadcrumb in Zircon Profile 8.0
Same name and namespace in other branches
- 8 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 RefinableCacheableDependencyInterface, RenderableInterface uses RefinableCacheableDependencyTrait
Expanded class hierarchy of Breadcrumb
8 files declare their use of Breadcrumb
- BookBreadcrumbBuilder.php in core/
modules/ book/ src/ BookBreadcrumbBuilder.php - Contains \Drupal\book\BookBreadcrumbBuilder.
- BreadcrumbManagerTest.php in core/
tests/ Drupal/ Tests/ Core/ Breadcrumb/ BreadcrumbManagerTest.php - Contains \Drupal\Tests\Core\Breadcrumb\BreadcrumbManagerTest.
- BreadcrumbTest.php in core/
tests/ Drupal/ Tests/ Core/ Breadcrumb/ BreadcrumbTest.php - Contains \Drupal\Tests\Core\Breadcrumb\BreadcrumbTest.
- CommentBreadcrumbBuilder.php in core/
modules/ comment/ src/ CommentBreadcrumbBuilder.php - Contains \Drupal\comment\CommentBreadcrumbBuilder.
- ForumBreadcrumbBuilderBase.php in core/
modules/ forum/ src/ Breadcrumb/ ForumBreadcrumbBuilderBase.php - Contains \Drupal\forum\Breadcrumb\ForumBreadcrumbBuilderBase.
4 string references to 'Breadcrumb'
- bartik.info.yml in core/
themes/ bartik/ bartik.info.yml - core/themes/bartik/bartik.info.yml
- seven.info.yml in core/
themes/ seven/ seven.info.yml - core/themes/seven/seven.info.yml
- ThemeHandler::rebuildThemeData in core/
lib/ Drupal/ Core/ Extension/ ThemeHandler.php - Scans and collects theme extension data and their engines.
- zircon.info.yml in themes/
zircon/ zircon.info.yml - themes/zircon/zircon.info.yml
File
- core/
lib/ Drupal/ Core/ Breadcrumb/ Breadcrumb.php, line 18 - Contains \Drupal\Core\Breadcrumb\Breadcrumb.
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;
}
}