You are here

public function TaxonomyMenuHelper::removeTaxonomyMenuEntries in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 modules/taxonomy_menu/src/TaxonomyMenuHelper.php \Drupal\taxonomy_menu\TaxonomyMenuHelper::removeTaxonomyMenuEntries()

Remove menu entries associate with the vocabulary of this term.

Parameters

\Drupal\taxonomy\TermInterface $term:

File

modules/taxonomy_menu/src/TaxonomyMenuHelper.php, line 99
Contains Drupal\taxonomy_menu\Controller\TaxonomyMenu.

Class

TaxonomyMenuHelper
Class TaxonomyMenu.

Namespace

Drupal\taxonomy_menu

Code

public function removeTaxonomyMenuEntries(TermInterface $term, $rebuild_all = TRUE) {

  // Load relevant taxonomy menus.
  $tax_menus = $this
    ->getTermMenusByVocabulary($term
    ->getVocabularyId());
  foreach ($tax_menus as $menu) {
    foreach (array_keys($menu
      ->getLinks([], TRUE)) as $plugin_id) {
      if (!$rebuild_all) {
        $plugin_id_parts = explode('.', $plugin_id);
        $term_id = array_pop($plugin_id_parts);
        if ($term
          ->id() != $term_id) {
          continue;
        }
      }
      $this->manager
        ->removeDefinition($plugin_id, FALSE);
    }
  }
}