1922de6e5c7e235269ddaaf58703c4f4bf809da4
[yaffs-website] / web / modules / contrib / slick / src / Plugin / Field / FieldFormatter / SlickFileFormatter.php
1 <?php
2
3 namespace Drupal\slick\Plugin\Field\FieldFormatter;
4
5 use Drupal\Core\Field\FieldDefinitionInterface;
6 use Drupal\blazy\Dejavu\BlazyVideoTrait;
7
8 /**
9  * Plugin implementation of the 'Slick File' formatter to get ME within images.
10  *
11  * This is not 'Slick Media', instead a simple mix of image and optional video.
12  */
13 class SlickFileFormatter extends SlickFileFormatterBase {
14
15   use SlickFormatterTrait;
16   use BlazyVideoTrait;
17
18   /**
19    * {@inheritdoc}
20    */
21   public function buildSettings() {
22     return ['blazy' => TRUE] + parent::getSettings();
23   }
24
25   /**
26    * {@inheritdoc}
27    */
28   public function getScopedFormElements() {
29     return [
30       'fieldable_form' => TRUE,
31       'multimedia'     => TRUE,
32       'view_mode'      => $this->viewMode,
33     ] + parent::getScopedFormElements();
34   }
35
36   /**
37    * {@inheritdoc}
38    */
39   public static function isApplicable(FieldDefinitionInterface $field_definition) {
40     $storage = $field_definition->getFieldStorageDefinition();
41     return $storage->isMultiple() && $storage->getSetting('target_type') === 'file';
42   }
43
44 }