function Breadcrumb::setLinks

Same name in other branches
  1. 9 core/lib/Drupal/Core/Breadcrumb/Breadcrumb.php \Drupal\Core\Breadcrumb\Breadcrumb::setLinks()
  2. 8.9.x core/lib/Drupal/Core/Breadcrumb/Breadcrumb.php \Drupal\Core\Breadcrumb\Breadcrumb::setLinks()
  3. 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;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.