You are here

private function PageContext::setFields 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::setFields()
  2. 8.3 src/Service/Context/PageContext.php \Drupal\acquia_lift\Service\Context\PageContext::setFields()

Set fields.

Parameters

\Drupal\node\NodeInterface $node: Node.

1 call to PageContext::setFields()
PageContext::setContextByNode in src/Service/Context/PageContext.php
Set page context by Node.

File

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

Class

PageContext

Namespace

Drupal\acquia_lift\Service\Context

Code

private function setFields(NodeInterface $node) {
  $available_field_vocabulary_names = $this
    ->getAvailableFieldVocabularyNames($node);
  $vocabulary_term_names = $this
    ->getVocabularyTermNames($node);

  // Find Field Term names.
  foreach ($available_field_vocabulary_names as $page_context_name => $vocabulary_names) {
    $field_term_names = $this
      ->getFieldTermNames($vocabulary_names, $vocabulary_term_names);

    // Only set when the value is a populated array
    // Empty arrays return as false in PHP.
    if (!empty($field_term_names)) {
      $this->htmlHeadContexts[$page_context_name] = implode(',', $field_term_names);
    }
  }
}