You are here

public static function PluginConfiguration::validatePluginConfiguration in Commerce Core 8.2

Validates the plugin configuration.

Parameters

array $element: An associative array containing the properties of the element.

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

array $complete_form: The complete form structure.

File

src/Element/PluginConfiguration.php, line 118

Class

PluginConfiguration
Provides a form element for configuring plugins.

Namespace

Drupal\commerce\Element

Code

public static function validatePluginConfiguration(array &$element, FormStateInterface $form_state, array &$complete_form) {
  if (!empty($element['#plugin_id'])) {

    /** @var \Drupal\Component\Plugin\PluginManagerInterface $plugin_manager */
    $plugin_manager = \Drupal::service('plugin.manager.' . $element['#plugin_type']);
    $plugin = $plugin_manager
      ->createInstance($element['#plugin_id'], $element['#default_value']);
    $plugin
      ->validateConfigurationForm($element['form'], $form_state);
  }
}