public function TaxonomyMenuHelper::generateTaxonomyMenuEntries in Zircon Profile 8
Same name and namespace in other branches
- 8.0 modules/taxonomy_menu/src/TaxonomyMenuHelper.php \Drupal\taxonomy_menu\TaxonomyMenuHelper::generateTaxonomyMenuEntries()
Create menu entries associate with the vocabulary of this term.
Parameters
\Drupal\taxonomy\TermInterface $term:
File
- modules/
taxonomy_menu/ src/ TaxonomyMenuHelper.php, line 50 - Contains Drupal\taxonomy_menu\Controller\TaxonomyMenu.
Class
- TaxonomyMenuHelper
- Class TaxonomyMenu.
Namespace
Drupal\taxonomy_menuCode
public function generateTaxonomyMenuEntries(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_parts = explode('.', $plugin_id);
$term_id = array_pop($plugin_id_parts);
if ($term
->id() != $term_id) {
continue;
}
}
if ($this->manager
->hasDefinition($plugin_id)) {
$this->manager
->updateDefinition($plugin_id, $plugin_def);
}
else {
$this->manager
->addDefinition($plugin_id, $plugin_def);
}
}
}
}