You are here

public function FeedsYouTubeFetcherFeedForm::validateConfigurationForm in Feeds: YouTube Parser 8

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 ExternalPluginFormBase::validateConfigurationForm

File

src/Feeds/Fetcher/Form/FeedsYouTubeFetcherFeedForm.php, line 165

Class

FeedsYouTubeFetcherFeedForm
Provides a form on the feed edit page for the FeedsYouTubeFetcher.

Namespace

Drupal\feeds_youtube\Feeds\Fetcher\Form

Code

public function validateConfigurationForm(array &$form, FormStateInterface $form_state, FeedInterface $feed = NULL) {
  $source = $form_state
    ->getValue('source');
  try {
    $test = $this->plugin
      ->requestUrl($source);
  } catch (\Google_Service_Exception $e) {
    $form_state
      ->setError($form['source'], $this
      ->t('A service error occurred: %error', [
      '%error' => htmlspecialchars($e
        ->getMessage()),
    ]));
  } catch (\Google_Exception $e) {
    $form_state
      ->setError($form['source'], $this
      ->t('A client error occurred: %error', [
      '%error' => htmlspecialchars($e
        ->getMessage()),
    ]));
  }
}