You are here

public function VideoFormatter::settingsForm in Facebook Instant Articles 8.2

Same name and namespace in other branches
  1. 3.x src/Plugin/Field/FieldFormatter/VideoFormatter.php \Drupal\fb_instant_articles\Plugin\Field\FieldFormatter\VideoFormatter::settingsForm()

Returns a form to configure settings for the formatter.

Invoked from \Drupal\field_ui\Form\EntityDisplayFormBase to allow administrators to configure the formatter. The field_ui module takes care of handling submitted form values.

Parameters

array $form: The form where the settings form is being included in.

\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.

Return value

array The form elements for the formatter settings.

Overrides DescriptionAwareFileFormatterBase::settingsForm

File

src/Plugin/Field/FieldFormatter/VideoFormatter.php, line 78

Class

VideoFormatter
Plugin implementation of the 'fbia_video' formatter.

Namespace

Drupal\fb_instant_articles\Plugin\Field\FieldFormatter

Code

public function settingsForm(array $form, FormStateInterface $form_state) {
  $element['presentation'] = [
    '#type' => 'select',
    '#title' => $this
      ->t('Presentation'),
    '#default_value' => $this
      ->getSetting('presentation'),
    '#options' => [
      Video::ASPECT_FIT => $this
        ->presentationLabel(Video::ASPECT_FIT),
      Video::ASPECT_FIT_ONLY => $this
        ->presentationLabel(Video::ASPECT_FIT_ONLY),
      Video::FULLSCREEN => $this
        ->presentationLabel(Video::FULLSCREEN),
      Video::NON_INTERACTIVE => $this
        ->presentationLabel(Video::NON_INTERACTIVE),
    ],
    '#empty_option' => $this
      ->t('None'),
  ];
  $element['controls'] = [
    '#type' => 'checkbox',
    '#title' => $this
      ->t('Enable player controls'),
    '#default_value' => $this
      ->getSetting('controls'),
  ];
  $element['autoplay'] = [
    '#type' => 'checkbox',
    '#title' => $this
      ->t('Enable autoplay'),
    '#default_value' => $this
      ->getSetting('autoplay'),
  ];
  $element['feed_cover'] = [
    '#type' => 'checkbox',
    '#title' => $this
      ->t('Newsfeed cover'),
    '#description' => $this
      ->t('Enable this setting to use this video as the cover when the article is shown in the newsfeed. If set, the first video in a multivalue field is used as the cover.'),
    '#default_value' => $this
      ->getSetting('feed_cover'),
  ];
  return $element;
}