You are here

private function PageContext::getVocabularyTermNames in Acquia Lift Connector 8.4

Same name and namespace in other branches
  1. 8 src/Service/Context/PageContext.php \Drupal\acquia_lift\Service\Context\PageContext::getVocabularyTermNames()
  2. 8.3 src/Service/Context/PageContext.php \Drupal\acquia_lift\Service\Context\PageContext::getVocabularyTermNames()

Get Vocabularies' Term names.

Parameters

\Drupal\node\NodeInterface $node: Node.

Return value

array Vocabularies' Term names.

1 call to PageContext::getVocabularyTermNames()
PageContext::setFields in src/Service/Context/PageContext.php
Set fields.

File

src/Service/Context/PageContext.php, line 344

Class

PageContext

Namespace

Drupal\acquia_lift\Service\Context

Code

private function getVocabularyTermNames(NodeInterface $node) {

  // Find the node's terms.
  $terms = $this->taxonomyTermStorage
    ->getNodeTerms([
    $node
      ->id(),
  ]);
  $node_terms = isset($terms[$node
    ->id()]) ? $terms[$node
    ->id()] : [];

  // Find the term names.
  $vocabulary_term_names = [];
  foreach ($node_terms as $term) {
    $vocabulary_id = $term
      ->bundle();
    $term_name = $term
      ->getName();
    $vocabulary_term_names[$vocabulary_id][] = $term_name;
  }
  return $vocabulary_term_names;
}