getParameter('taxonomy_term'); if (!$term instanceof TermInterface) { return NULL; } if (!$this->handlesEntity($term)) { return NULL; } return $term; } /** * {@inheritdoc} */ public function buildBreadcrumb(Breadcrumb $breadcrumb, EntityInterface $entity): void { if (!$entity instanceof TermInterface) { return; } // Add all ancestors in the taxonomy hierarchy. $term_storage = $this->entityTypeManager->getStorage('taxonomy_term'); $ancestors = $term_storage->loadAllParents($entity->id()); $ancestors = array_reverse($ancestors); foreach ($ancestors as $ancestor) { $breadcrumb->addCacheableDependency($ancestor); $breadcrumb->addLink($ancestor->toLink()); } } /** * {@inheritdoc} */ public function getSiteSectionId(EntityInterface $entity): int|string|null { if (!$entity instanceof TermInterface) { return NULL; } // Only site_section terms can be site sections. if ($entity->bundle() !== 'site_section') { return NULL; } return $entity->id(); } }