You are here

public function Breadcrumb::setLinks in Drupal 8

Same name and namespace in other branches
  1. 9 core/lib/Drupal/Core/Breadcrumb/Breadcrumb.php \Drupal\Core\Breadcrumb\Breadcrumb::setLinks()
  2. 10 core/lib/Drupal/Core/Breadcrumb/Breadcrumb.php \Drupal\Core\Breadcrumb\Breadcrumb::setLinks()

Sets the breadcrumb links.

Parameters

\Drupal\Core\Link[] $links: The breadcrumb links.

Return value

$this

Throws

\LogicException Thrown when setting breadcrumb links after they've already been set.

File

core/lib/Drupal/Core/Breadcrumb/Breadcrumb.php, line 44

Class

Breadcrumb
Used to return generated breadcrumbs with associated cacheability metadata.

Namespace

Drupal\Core\Breadcrumb

Code

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;
}