You are here

protected function VideoEmbedDialog::getClientValues in Video Embed Field 8

Same name and namespace in other branches
  1. 8.2 modules/video_embed_wysiwyg/src/Form/VideoEmbedDialog.php \Drupal\video_embed_wysiwyg\Form\VideoEmbedDialog::getClientValues()

Get the values from the form and provider required for the client.

Parameters

\Drupal\Core\Form\FormStateInterface $form_state: The form state from the dialog submission.

\Drupal\video_embed_field\ProviderPluginInterface $provider: The provider loaded from the user input.

Return value

array An array of values sent to the client for use in the WYSIWYG.

1 call to VideoEmbedDialog::getClientValues()
VideoEmbedDialog::ajaxSubmit in modules/video_embed_wysiwyg/src/Form/VideoEmbedDialog.php
An AJAX submit callback to validate the WYSIWYG modal.

File

modules/video_embed_wysiwyg/src/Form/VideoEmbedDialog.php, line 139

Class

VideoEmbedDialog
A class for a video embed dialog.

Namespace

Drupal\video_embed_wysiwyg\Form

Code

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(),
  ];
}