You are here

public function TaxonomyTreeBuilder::loadTree in Entity Reference Tree Widget 2.x

Same name and namespace in other branches
  1. 8 src/Tree/TaxonomyTreeBuilder.php \Drupal\entity_reference_tree\Tree\TaxonomyTreeBuilder::loadTree()

Load all entities from an entity bundle for the tree.

Parameters

string $entityType: The type of the entity.

string $bundleID: The bundle ID.

Return value

array All entities in the entity bundle.

Overrides TreeBuilderInterface::loadTree

File

src/Tree/TaxonomyTreeBuilder.php, line 44

Class

TaxonomyTreeBuilder
Provides a class for building a tree from taxonomy entity.

Namespace

Drupal\entity_reference_tree\Tree

Code

public function loadTree(string $entityType, string $bundleID, string $langCode = NULL, int $parent = 0, int $max_depth = NULL) {

  // Setup the language code for this tree.
  // Use current language by default.
  if (empty($langCode)) {
    $this->langCode = \Drupal::service('language_manager')
      ->getCurrentLanguage()
      ->getId();
  }
  else {
    $this->langCode = $langCode;
  }
  if ($this
    ->hasAccess()) {
    return \Drupal::entityTypeManager()
      ->getStorage($entityType)
      ->loadTree($bundleID, $parent, $max_depth);
  }

  // The user is not allowed to access taxonomy overviews.
  return NULL;
}