Yaffs site version 1.1
[yaffs-website] / web / modules / contrib / blazy / src / Plugin / Field / FieldFormatter / BlazyFormatterBaseTrait.php
diff --git a/web/modules/contrib/blazy/src/Plugin/Field/FieldFormatter/BlazyFormatterBaseTrait.php b/web/modules/contrib/blazy/src/Plugin/Field/FieldFormatter/BlazyFormatterBaseTrait.php
new file mode 100644 (file)
index 0000000..46444f6
--- /dev/null
@@ -0,0 +1,48 @@
+<?php
+
+namespace Drupal\blazy\Plugin\Field\FieldFormatter;
+
+/**
+ * A Trait common for blazy image, video and file ER formatters.
+ */
+trait BlazyFormatterBaseTrait {
+
+  /**
+   * The blazy manager service.
+   *
+   * @var \Drupal\blazy\BlazyFormatterManager
+   */
+  protected $blazyManager;
+
+  /**
+   * Returns the blazy manager.
+   */
+  public function blazyManager() {
+    return $this->blazyManager;
+  }
+
+  /**
+   * Builds the settings.
+   */
+  public function buildSettings() {
+    $settings              = $this->getSettings();
+    $settings['plugin_id'] = $this->getPluginId();
+
+    return $settings;
+  }
+
+  /**
+   * Returns the blazy admin service.
+   */
+  public function admin() {
+    return \Drupal::service('blazy.admin.formatter');
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function settingsSummary() {
+    return $this->admin()->getSettingsSummary($this->getScopedFormElements());
+  }
+
+}