You are here

public function ContextMetadata::submitConfigurationForm 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::submitConfigurationForm()

File

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

Class

ContextMetadata
Provides a content reaction that adds a Metadata.

Namespace

Drupal\context_metadata\Plugin\ContextReaction

Code

public function submitConfigurationForm(array &$form, FormStateInterface $form_state) {

  // TODO DI metatag.manager service.
  $metatagManager = \Drupal::service('metatag.manager');
  $sortedTags = $metatagManager
    ->sortedTags();
  $conf = [];
  foreach ($sortedTags as $tagId => $tagDefinition) {
    if ($form_state
      ->hasValue([
      $tagDefinition['group'],
      $tagId,
    ])) {
      $conf[$tagId] = $form_state
        ->getValue([
        $tagDefinition['group'],
        $tagId,
      ]);
    }
  }
  $this
    ->setConfiguration($conf);
}