You are here

public function MessagePurgePluginManager::getPurgeConfiguration in Message 8

Gather the purge plugin settings on form submission.

Parameters

array $form: The form array.

\Drupal\Core\Form\FormStateInterface $form_state: The form state.

Return value

array The purge plugin configurations that are enabled, keyed by plugin ID.

File

src/MessagePurgePluginManager.php, line 134

Class

MessagePurgePluginManager
Plugin type manager for MessagePurge plugins.

Namespace

Drupal\message

Code

public function getPurgeConfiguration(array $form, FormStateInterface $form_state) {
  $purge_plugins = [];
  foreach ($form_state
    ->getValue([
    'settings',
    'purge_methods',
  ]) as $plugin_id => $configuration) {
    if ($configuration['enabled']) {

      /** @var \Drupal\message\MessagePurgeInterface $plugin */
      $plugin = $this
        ->createInstance($plugin_id, $configuration);
      $plugin
        ->submitConfigurationForm($form, $form_state);
      $purge_plugins[$plugin_id] = $plugin
        ->getConfiguration();
    }
  }
  return $purge_plugins;
}