You are here

protected static function AdvancedPluginSelectorBase::setPluginSelector in Plugin 8.2

Stores a plugin selector in the form state.

Parameters

\Drupal\Core\Form\FormStateInterface:

\Drupal\plugin\Plugin\Plugin\PluginSelector\PluginSelectorInterface:

Return value

string[] The form state storage key that contains the plugin selector.

Throws

\InvalidArgumentException

1 call to AdvancedPluginSelectorBase::setPluginSelector()
AdvancedPluginSelectorBase::buildSelectorForm in src/Plugin/Plugin/PluginSelector/AdvancedPluginSelectorBase.php
Builds the selector form.

File

src/Plugin/Plugin/PluginSelector/AdvancedPluginSelectorBase.php, line 101

Class

AdvancedPluginSelectorBase
Provides a default base for most plugin selectors.

Namespace

Drupal\plugin\Plugin\Plugin\PluginSelector

Code

protected static function setPluginSelector(FormStateInterface $form_state, PluginSelectorInterface $plugin_selector) {
  do {
    $key = [
      get_class(),
      mt_rand(),
    ];
  } while ($form_state
    ->has($key));
  $form_state
    ->set($key, $plugin_selector);
  return $key;
}