public static function FaqHelper::setFaqBreadcrumb in Frequently Asked Questions 8
Function to set up the FAQ breadcrumbs for a given taxonomy term.
Parameters
null $term:
Return value
array
1 call to FaqHelper::setFaqBreadcrumb()
- faq_preprocess_page in ./
faq.module - Implements template_preprocess_page().
File
- src/
FaqHelper.php, line 22
Class
- FaqHelper
- Contains static helper functions for FAQ module.
Namespace
Drupal\faqCode
public static function setFaqBreadcrumb($term = NULL) {
$faq_settings = \Drupal::config('faq.settings');
$site_settings = \Drupal::config('system.site');
$breadcrumb = array();
if ($faq_settings
->get('custom_breadcrumbs')) {
if (\Drupal::moduleHandler()
->moduleExists('taxonomy') && $term) {
$breadcrumb[] = Link::fromTextAndUrl(t($term
->getName()), Url::fromUserInput('/faq-page/' . $term
->id()));
$breadcrumb[] = Link::fromTextAndUrl(t($term
->getName()), Url::fromUserInput('/faq-page/' . $term
->id()));
while ($parents = \Drupal::entityTypeManager()
->getStorage('taxonomy_term')
->loadParents($term
->id())) {
$term = array_shift($parents);
$breadcrumb[] = Link::fromTextAndUrl(t($term
->getName()), Url::fromUserInput('/faq-page/' . $term
->id()));
}
}
$breadcrumb[] = Link::fromTextAndUrl($faq_settings
->get('title'), Url::fromUserInput('/faq-page'));
$breadcrumb[] = Link::fromTextAndUrl(t('Home'), Url::fromRoute('<front>')
->setOptions(array(
'attributes' => array(
'title' => $site_settings
->get('name'),
),
)));
$breadcrumb = array_reverse($breadcrumb);
}
return $breadcrumb;
}