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