You are here

public function OEmbed::validateConfigurationForm in Drupal 9

Same name and namespace in other branches
  1. 8 core/modules/media/src/Plugin/media/Source/OEmbed.php \Drupal\media\Plugin\media\Source\OEmbed::validateConfigurationForm()

Form validation handler.

Parameters

array $form: An associative array containing the structure of the plugin form as built by static::buildConfigurationForm().

\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form. Calling code should pass on a subform state created through \Drupal\Core\Form\SubformState::createForSubform().

Overrides MediaSourceBase::validateConfigurationForm

File

core/modules/media/src/Plugin/media/Source/OEmbed.php, line 345

Class

OEmbed
Provides a media source plugin for oEmbed resources.

Namespace

Drupal\media\Plugin\media\Source

Code

public function validateConfigurationForm(array &$form, FormStateInterface $form_state) {
  $thumbnails_directory = $form_state
    ->getValue('thumbnails_directory');

  /** @var \Drupal\Core\StreamWrapper\StreamWrapperManagerInterface $stream_wrapper_manager */
  $stream_wrapper_manager = \Drupal::service('stream_wrapper_manager');
  if (!$stream_wrapper_manager
    ->isValidUri($thumbnails_directory)) {
    $form_state
      ->setErrorByName('thumbnails_directory', $this
      ->t('@path is not a valid path.', [
      '@path' => $thumbnails_directory,
    ]));
  }
}