private function getCategories($campaignId) {
    $categories = [];

    /** @var \Drupal\node\Entity\Node $campaign */
    $campaign = $this->entityTypeManager->getStorage('taxonomy_vocabulary')->load($campaignId);

    /** @var \Drupal\taxonomy\Entity\Vocabulary $vocabulary */
    $vocabulary = $campaign->field_campaign_fitness_category->entity;
    /** @var \Drupal\taxonomy\VocabularyStorageInterface $vocabularyStorage */
    $vocabularyStorage = $this->entityTypeManager->getStorage('taxonomy_vocabulary');
    $tids = $vocabularyStorage->getToplevelTids([$vocabulary->id()]);

    $terms = $this->taxonomyStorage->loadMultiple($tids);
    /** @var \Drupal\taxonomy\Entity\Term $term */
    foreach ($terms as $term) {
      $categories[$term->id()] = $term->getName();
    }
    return $categories;
  }
private function getCategories($campaignId) {
    $categories = [];

    /** @var \Drupal\node\Entity\Node $campaign */
    $campaign = $this->entityTypeManager->getStorage('taxonomy_vocabulary')->load($campaignId);

    /** @var \Drupal\taxonomy\Entity\Vocabulary $vocabulary */
    $vocabulary = $campaign->field_campaign_fitness_category->entity;
    /** @var \Drupal\taxonomy\VocabularyStorageInterface $vocabularyStorage */
    $vocabularyStorage = $this->entityTypeManager->getStorage('taxonomy_vocabulary');
    $tids = $vocabularyStorage->getToplevelTids([$vocabulary->id()]);

    $terms = $this->taxonomyStorage->loadMultiple($tids);
    /** @var \Drupal\taxonomy\Entity\Term $term */
    foreach ($terms as $term) {
      $categories[$term->id()] = $term->getName();
    }
    return $categories;
  }
private function getCategories ( $ campaignId ) { $ categories = [ ] ; /** @var \Drupal\node\Entity\Node $campaign */ $ campaign = $ this -> entityTypeManager -> getStorage ( 'taxonomy_vocabulary' ) -> load ( $ campaignId ) ; /** @var \Drupal\taxonomy\Entity\Vocabulary $vocabulary */ $ vocabulary = $ campaign -> field_campaign_fitness_category -> entity ; /** @var \Drupal\taxonomy\VocabularyStorageInterface $vocabularyStorage */ $ vocabularyStorage = $ this -> entityTypeManager -> getStorage ( 'taxonomy_vocabulary' ) ; $ tids = $ vocabularyStorage -> getToplevelTids ( [ $ vocabulary -> id ( ) ] ) ; $ terms = $ this -> taxonomyStorage -> loadMultiple ( $ tids ) ; /** @var \Drupal\taxonomy\Entity\Term $term */ foreach ( $ terms as $ term ) { $ categories [ $ term -> id ( ) ] = $ term -> getName ( ) ; } return $ categories ; }
Get all categories of the campaign.

@param int $campaignId

@return \Drupal\Core\Entity\EntityInterface[]
@throws \Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException
Get all categories of the campaign .