96c6b53ece2054d67c074be542b0551cab7839c6
[yaffs-website] / web / modules / contrib / blazy / src / Dejavu / BlazyVideoBase.php
1 <?php
2
3 namespace Drupal\blazy\Dejavu;
4
5 use Drupal\Core\Field\FormatterBase;
6 use Drupal\Core\Form\FormStateInterface;
7
8 /**
9  * Base class for blazy video embed field formatters.
10  */
11 abstract class BlazyVideoBase extends FormatterBase {
12
13   /**
14    * {@inheritdoc}
15    */
16   public static function defaultSettings() {
17     return BlazyDefault::extendedSettings();
18   }
19
20   /**
21    * {@inheritdoc}
22    */
23   public function settingsForm(array $form, FormStateInterface $form_state) {
24     $element    = [];
25     $definition = $this->getScopedFormElements();
26
27     $definition['_views'] = isset($form['field_api_classes']);
28
29     $this->admin()->buildSettingsForm($element, $definition);
30     $element['media_switch']['#options']['media'] = $this->t('Image to iFrame');
31
32     return $element;
33   }
34
35   /**
36    * Defines the scope for the form elements.
37    */
38   public function getScopedFormElements() {
39     $field       = $this->fieldDefinition;
40     $entity_type = $field->getTargetEntityTypeId();
41     $target_type = $this->getFieldSetting('target_type');
42
43     return [
44       'background'        => TRUE,
45       'breakpoints'       => BlazyDefault::getConstantBreakpoints(),
46       'current_view_mode' => $this->viewMode,
47       'entity_type'       => $entity_type,
48       'field_name'        => $this->fieldDefinition->getName(),
49       'image_style_form'  => TRUE,
50       'media_switch_form' => TRUE,
51       'multimedia'        => TRUE,
52       'settings'          => $this->getSettings(),
53       'target_type'       => $target_type,
54       'thumb_positions'   => TRUE,
55       'nav'               => TRUE,
56     ];
57   }
58
59 }