You are here

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

Form submission 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::submitConfigurationForm

File

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

Class

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

Namespace

Drupal\feeds_youtube\Feeds\Fetcher\Form

Code

public function submitConfigurationForm(array &$form, FormStateInterface $form_state, FeedInterface $feed = NULL) {
  if ($form_state
    ->getValue([
    'google_access_token',
    'revoke_access',
  ])) {

    // Revoke access token.
    $client = $this->plugin
      ->getClientFactory($feed
      ->id());
    $client
      ->revokeToken($client
      ->getAccessToken());

    // Clear cached token.
    Cache::invalidateTags([
      $this->plugin
        ->getAccessTokenCacheId($feed
        ->id()),
    ]);

    // Let user know the access token has been revoked.
    \Drupal::messenger()
      ->addStatus($this
      ->t('Google API access token revoked.'));
  }
  $feed
    ->setSource($form_state
    ->getValue('source'));
}