You are here

public function ContextMetadata::buildConfigurationForm in Context Metadata 8.2

Same name and namespace in other branches
  1. 8 src/Plugin/ContextReaction/ContextMetadata.php \Drupal\context_metadata\Plugin\ContextReaction\ContextMetadata::buildConfigurationForm()

File

src/Plugin/ContextReaction/ContextMetadata.php, line 21

Class

ContextMetadata
Provides a content reaction that adds a Metadata.

Namespace

Drupal\context_metadata\Plugin\ContextReaction

Code

public function buildConfigurationForm(array $form, FormStateInterface $form_state) {

  // TODO DI metatag.manager service.
  $metatagManager = \Drupal::service('metatag.manager');

  // Get the sorted tags.
  $sortedTags = $metatagManager
    ->sortedTags();
  $values = [];

  // Check previous values.
  foreach ($sortedTags as $tagId => $tagDefinition) {
    if (isset($this
      ->getConfiguration()[$tagId])) {
      $values[$tagId] = $this
        ->getConfiguration()[$tagId];
    }
  }

  // Get the base metatag form.
  $form = $metatagManager
    ->form($values, []);
  return $form;
}