You are here

private function MenuTree::calculateItemCssClass in Taxonomy Facets 8

1 call to MenuTree::calculateItemCssClass()
MenuTree::buildMenuTreeRecursively in src/MenuTree.php

File

src/MenuTree.php, line 77

Class

MenuTree

Namespace

Drupal\taxonomy_facets

Code

private function calculateItemCssClass($menuItemInChildrenLeafs, $tid) {

  // Check if the current term in this loop has any children.
  $hasChildren = \Drupal::entityTypeManager()
    ->getStorage('taxonomy_term')
    ->loadTree($this->vid, $tid, 1);
  $return['leafClass'] = 'menu-item';
  if ($hasChildren) {
    if ($menuItemInChildrenLeafs || $this
      ->menuItemIsFilterApplied($tid)) {
      $return['leafClass'] .= ' menu-item--expanded menu-item--active-trail';
    }
    else {
      $return['leafClass'] .= ' menu-item--collapsed';
    }
  }
  $return['leafAnchorClass'] = NULL;
  if ($this
    ->menuItemIsFilterApplied($tid)) {
    $return['leafAnchorClass'] = "is-active";
  }
  return $return;
}