/**
  * Get the values from the form and provider required for the client.
  *
  * @param \Drupal\Core\Form\FormStateInterface $form_state
  *   The form state from the dialog submission.
  * @param \Drupal\video_embed_field\ProviderPluginInterface $provider
  *   The provider loaded from the user input.
  *
  * @return array
  *   An array of values sent to the client for use in the WYSIWYG.
  */
 protected function getClientValues(FormStateInterface $form_state, ProviderPluginInterface $provider)
 {
     // All settings from the field formatter exist in the form and are relevant
     // for the rendering of the video.
     $video_formatter_settings = Video::defaultSettings();
     foreach ($video_formatter_settings as $key => $default) {
         $video_formatter_settings[$key] = $form_state->getValue($key);
     }
     $provider->downloadThumbnail();
     $thumbnail_preview = ImageStyle::load('video_embed_wysiwyg_preview')->buildUrl($provider->getLocalThumbnailUri());
     $thumbnail_preview_parts = parse_url($thumbnail_preview);
     return ['preview_thumbnail' => $thumbnail_preview_parts['path'] . (!empty($thumbnail_preview_parts['query']) ? '?' : '') . $thumbnail_preview_parts['query'], 'video_url' => $form_state->getValue('video_url'), 'settings' => $video_formatter_settings, 'settings_summary' => Video::mockInstance($video_formatter_settings)->settingsSummary()];
 }
Exemple #2
0
 /**
  * Get the values from the form and provider required for the client.
  *
  * @param \Drupal\Core\Form\FormStateInterface $form_state
  *   The form state from the dialog submission.
  * @param \Drupal\video_embed_field\ProviderPluginInterface $provider
  *   The provider loaded from the user input.
  *
  * @return array
  *   An array of values sent to the client for use in the WYSIWYG.
  */
 protected function getClientValues(FormStateInterface $form_state, $provider)
 {
     // @todo Render the thumbnail to download it from the remote. Consider
     // making the download method public. https://www.drupal.org/node/2687077
     $provider->renderThumbnail(FALSE, FALSE);
     // All settings from the field formatter exist in the form and are relevant
     // for the rendering of the video.
     $video_formatter_settings = Video::defaultSettings();
     foreach ($video_formatter_settings as $key => $default) {
         $video_formatter_settings[$key] = $form_state->getValue($key);
     }
     return ['preview_thumbnail' => ImageStyle::load('video_embed_wysiwyg_preview')->buildUrl($provider->getLocalThumbnailUri()), 'video_url' => $form_state->getValue('video_url'), 'settings' => $video_formatter_settings, 'settings_summary' => $this->getVideoFormatterInstance($video_formatter_settings)->settingsSummary()];
 }