You are here

public function TaxonomyMenu::getLinks in Zircon Profile 8.0

Same name and namespace in other branches
  1. 8 modules/taxonomy_menu/src/Entity/TaxonomyMenu.php \Drupal\taxonomy_menu\Entity\TaxonomyMenu::getLinks()

Get menu link plugin definitions

Parameters

array $base_plugin_definition:

bool $include_base_plugin_id: If true, 'taxonomy_menu.menu_link:' will be prepended to the returned plugin ids.

Return value

array

Overrides TaxonomyMenuInterface::getLinks

3 calls to TaxonomyMenu::getLinks()
TaxonomyMenu::delete in modules/taxonomy_menu/src/Entity/TaxonomyMenu.php
Deletes an entity permanently.
TaxonomyMenu::preSave in modules/taxonomy_menu/src/Entity/TaxonomyMenu.php
Acts on an entity before the presave hook is invoked.
TaxonomyMenu::save in modules/taxonomy_menu/src/Entity/TaxonomyMenu.php
Saves an entity permanently.

File

modules/taxonomy_menu/src/Entity/TaxonomyMenu.php, line 128
Contains Drupal\taxonomy_menu\Entity\TaxonomyMenu.

Class

TaxonomyMenu
Defines the TaxonomyMenu entity.

Namespace

Drupal\taxonomy_menu\Entity

Code

public function getLinks($base_plugin_definition = [], $include_base_plugin_id = FALSE) {

  /** @var $termStorage \Drupal\taxonomy\TermStorageInterface */
  $termStorage = $this
    ->entityManager()
    ->getStorage('taxonomy_term');

  // Load taxonomy terms for tax menu vocab.
  $terms = $termStorage
    ->loadTree($this
    ->getVocabulary());
  $links = [];

  // Create menu links for each term in the vocabulary.
  foreach ($terms as $term) {
    if (!$term instanceof \Drupal\taxonomy\TermInterface) {
      $term = Term::load($term->tid);
    }
    $mlid = $this
      ->buildMenuPluginId($term, $include_base_plugin_id);
    $links[$mlid] = $this
      ->buildMenuDefinition($term, $base_plugin_definition);
  }
  return $links;
}