/** * {@inheritdoc} */ public function settingsForm(array $form, FormStateInterface $form_state, Editor $editor) { $editor_settings = $editor->getSettings(); $plugin_settings = NestedArray::getValue($editor_settings, ['plugins', 'video_embed', 'defaults', 'children']); $settings = $plugin_settings ?: []; $form['defaults'] = ['#title' => $this->t('Default Settings'), '#type' => 'fieldset', '#tree' => TRUE, 'children' => Video::mockInstance($settings)->settingsForm([], new FormState())]; return $form; }
/** * 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()]; }