You are here

public function TaxonomyMenuHelper::updateTaxonomyMenuEntries in Zircon Profile 8

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

Update menu entries associate with the vocabulary of this term.

Parameters

\Drupal\taxonomy\TermInterface $term:

File

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

Class

TaxonomyMenuHelper
Class TaxonomyMenu.

Namespace

Drupal\taxonomy_menu

Code

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

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