You are here

class BgImageFormatter in Background Images Formatter 8.3

Same name and namespace in other branches
  1. 8 src/Plugin/Field/FieldFormatter/BgImageFormatter.php \Drupal\bg_image_formatter\Plugin\Field\FieldFormatter\BgImageFormatter
  2. 8.2 src/Plugin/Field/FieldFormatter/BgImageFormatter.php \Drupal\bg_image_formatter\Plugin\Field\FieldFormatter\BgImageFormatter

Class BgImageFormatter.

Plugin annotation


@FieldFormatter(
    id="bg_image_formatter",
    label=@Translation("Background Image"),
    field_types={"image"}
)

Hierarchy

Expanded class hierarchy of BgImageFormatter

1 file declares its use of BgImageFormatter
ResponsiveBgImageFormatter.php in modules/responsive_bg_image_formatter/src/Plugin/Field/FieldFormatter/ResponsiveBgImageFormatter.php

File

src/Plugin/Field/FieldFormatter/BgImageFormatter.php, line 29

Namespace

Drupal\bg_image_formatter\Plugin\Field\FieldFormatter
View source
class BgImageFormatter extends ImageFormatter {
  use AjaxHelperTrait;

  /**
   * The renderer service.
   *
   * @var \Drupal\Core\Render\RendererInterface
   */
  protected $renderer;

  /**
   * The current request.
   *
   * @var \Symfony\Component\HttpFoundation\Request
   */
  protected $request;

  /**
   * BgImageFormatter constructor.
   *
   * @param string $plugin_id
   *   The plugin_id for the formatter.
   * @param mixed $plugin_definition
   *   The plugin implementation definition.
   * @param \Drupal\Core\Field\FieldDefinitionInterface $field_definition
   *   The definition of the field to which the formatter is associated.
   * @param array $settings
   *   The formatter settings.
   * @param string $label
   *   The formatter label display setting.
   * @param string $view_mode
   *   The view mode.
   * @param array $third_party_settings
   *   Any third party settings settings.
   * @param \Drupal\Core\Session\AccountInterface $current_user
   *   The current user.
   * @param \Drupal\Core\Entity\EntityStorageInterface $image_style_storage
   *   The image style storage.
   * @param \Drupal\Core\Render\RendererInterface $renderer
   *   The renderer service.
   * @param \Symfony\Component\HttpFoundation\Request $request
   *   The current request.
   */
  public function __construct($plugin_id, $plugin_definition, FieldDefinitionInterface $field_definition, array $settings, $label, $view_mode, array $third_party_settings, AccountInterface $current_user, EntityStorageInterface $image_style_storage, RendererInterface $renderer, Request $request) {
    parent::__construct($plugin_id, $plugin_definition, $field_definition, $settings, $label, $view_mode, $third_party_settings, $current_user, $image_style_storage);
    $this->renderer = $renderer;
    $this->request = $request;
  }

  /**
   * {@inheritdoc}
   */
  public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
    return new static($plugin_id, $plugin_definition, $configuration['field_definition'], $configuration['settings'], $configuration['label'], $configuration['view_mode'], $configuration['third_party_settings'], $container
      ->get('current_user'), $container
      ->get('entity_type.manager')
      ->getStorage('image_style'), $container
      ->get('renderer'), $container
      ->get('request_stack')
      ->getCurrentRequest());
  }

  /**
   * {@inheritdoc}
   */
  public static function defaultSettings() {
    return [
      'image_style' => '',
      'css_settings' => [
        'bg_image_selector' => 'body',
        'bg_image_color' => '#FFFFFF',
        'bg_image_x' => 'left',
        'bg_image_y' => 'top',
        'bg_image_attachment' => 'scroll',
        'bg_image_repeat' => 'no-repeat',
        'bg_image_background_size' => '',
        'bg_image_background_size_ie8' => 0,
        'bg_image_gradient' => '',
        'bg_image_media_query' => 'all',
        'bg_image_important' => 1,
        'bg_image_z_index' => 'auto',
        'bg_image_path_format' => 'absolute',
      ],
    ];
  }

  /**
   * Function taken from the module 'bg_image'.
   *
   * Adds a background image to the page using the
   * css 'background' property.
   *
   * @param string $image_path
   *   The path of the image to use. This can be either
   *      - A relative path e.g. sites/default/files/image.png
   *      - A uri: e.g. public://image.png.
   * @param array $css_settings
   *   An array of css settings to use. Possible values are:
   *      - bg_image_selector: The css selector to use
   *      - bg_image_color: The background color
   *      - bg_image_x: The x offset
   *      - bg_image_y: The y offset
   *      - bg_image_attachment: The attachment property (scroll or fixed)
   *      - bg_image_repeat: The repeat settings
   *      - bg_image_background_size: The background size property if necessary
   *    Default settings will be used for any values not provided.
   * @param string $image_style
   *   Optionally add an image style to the image before applying it to the
   *   background.
   *
   * @return array
   *   The array containing the CSS.
   */
  public function getBackgroundImageCss($image_path, array $css_settings = [], $image_style = NULL) {
    $defaults = self::defaultSettings();
    $css_settings += $defaults['css_settings'];

    // Pull the default css setting if not provided.
    $selector = Xss::filter($css_settings['bg_image_selector']);
    $bg_color = Xss::filter($css_settings['bg_image_color']);
    $bg_x = Xss::filter($css_settings['bg_image_x']);
    $bg_y = Xss::filter($css_settings['bg_image_y']);
    $attachment = $css_settings['bg_image_attachment'];
    $repeat = $css_settings['bg_image_repeat'];
    $important = $css_settings['bg_image_important'];
    $background_size = Xss::filter($css_settings['bg_image_background_size']);
    $background_size_ie8 = $css_settings['bg_image_background_size_ie8'];
    $background_gradient = !empty($css_settings['bg_image_gradient']) ? $css_settings['bg_image_gradient'] . ',' : '';
    $media_query = isset($css_settings['bg_image_media_query']) ? Xss::filter($css_settings['bg_image_media_query']) : NULL;
    $z_index = Xss::filter($css_settings['bg_image_z_index']);

    // If important is true, we turn it into a string for css output.
    if ($important) {
      $important = '!important';
    }
    else {
      $important = '';
    }

    // Handle the background size property.
    $bg_size = '';
    $ie_bg_size = '';
    if ($background_size) {

      // CSS3.
      $bg_size = sprintf('background-size: %s %s;', $background_size, $important);

      // Let's cover ourselves for other browsers as well...
      $bg_size .= sprintf('-webkit-background-size: %s %s;', $background_size, $important);
      $bg_size .= sprintf('-moz-background-size: %s %s;', $background_size, $important);
      $bg_size .= sprintf('-o-background-size: %s %s;', $background_size, $important);

      // IE filters to apply the cover effect.
      if ($background_size === 'cover' && $background_size_ie8) {
        $ie_bg_size = sprintf("filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='%s', sizingMethod='scale');", $image_path);
        $ie_bg_size .= sprintf("-ms-filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='%s', sizingMethod='scale');", $image_path);
      }
    }

    // Add the css if we have everything we need.
    if ($selector && $image_path) {
      $style = sprintf('%s {', $selector);
      if ($bg_color) {
        $style .= sprintf('background-color: %s %s;', $bg_color, $important);
      }
      $style .= sprintf("background-image: %s url('%s') %s;", $background_gradient, $image_path, $important);
      if ($repeat) {
        $style .= sprintf('background-repeat: %s %s;', $repeat, $important);
      }
      if ($attachment) {
        $style .= sprintf('background-attachment: %s %s;', $attachment, $important);
      }
      if ($bg_x && $bg_y) {
        $style .= sprintf('background-position: %s %s %s;', $bg_x, $bg_y, $important);
      }
      if ($z_index) {
        $style .= sprintf('z-index: %s;', $z_index);
      }
      $style .= $bg_size;
      $style .= $background_size_ie8 ? $ie_bg_size : '';
      $style .= '}';
      return [
        'data' => $style,
        'media' => !empty($media_query) ? $media_query : 'all',
        'group' => CSS_THEME,
      ];
    }
    return [];
  }

  /**
   * {@inheritdoc}
   */
  public function settingsForm(array $form, FormStateInterface $form_state) {
    $element = [];
    $settings = $this
      ->getSettings();
    $element['image_style'] = [
      '#title' => $this
        ->t('Image style'),
      '#type' => 'select',
      '#default_value' => $settings['image_style'],
      '#empty_option' => $this
        ->t('None (original image)'),
      '#options' => image_style_options(),
      '#description' => $this
        ->t('Select <a href="@href_image_style">the image style</a> to apply on images', [
        '@href_image_style' => Url::fromRoute('image.style_add')
          ->toString(),
      ]),
    ];

    // Fieldset for css settings.
    $element['css_settings'] = [
      '#type' => 'fieldset',
      '#title' => $this
        ->t('Default CSS Settings'),
      '#description' => $this
        ->t('Default CSS settings for outputting the background property.
                These settings will be concatenated to form a complete css statementthat uses the "background"
                property. For more information on the css background property see
                http://www.w3schools.com/css/css_background.asp"'),
    ];

    // The selector for the background property.
    $element['css_settings']['bg_image_selector'] = [
      '#type' => 'textarea',
      '#title' => $this
        ->t('Selector(s)'),
      '#description' => $this
        ->t('A valid CSS selector that will be used to apply the background image. One per line.
                      If the field is a multivalue field, the first line will be applied to the first value,
                      the second to the second value... and so on. Tokens are supported.'),
      '#default_value' => $settings['css_settings']['bg_image_selector'],
    ];

    // The token help relevant to this entity type.
    if (isset($form['#entity_type'])) {
      $element['css_settings']['token_help'] = [
        '#theme' => 'token_tree_link',
        '#token_types' => [
          'user',
          $form['#entity_type'],
        ],
      ];
    }
    else {
      $element['css_settings']['token_help'] = [
        '#theme' => 'token_tree_link',
      ];
    }

    // The selector for the background property.
    $element['css_settings']['bg_image_z_index'] = [
      '#type' => 'textfield',
      '#title' => $this
        ->t('Z Index'),
      '#description' => $this
        ->t('The z-index property specifies the stack order of an element. An element with greater stack order is
                      always in front of an element with a lower stack order. Note: z-index only works on positioned
                      elements (position:absolute, position:relative, or position:fixed)'),
      '#default_value' => $settings['css_settings']['bg_image_z_index'],
    ];

    // The selector for the background property.
    $element['css_settings']['bg_image_color'] = [
      '#type' => 'textarea',
      '#title' => $this
        ->t('Color'),
      '#description' => $this
        ->t('The background color formatted as any valid css color format (e.g. hex, rgb, text, hsl)
                      [<a href="@url">css property: background-color</a>]. One per line. If the field is a multivalue
                      field, the first line will be applied to the first value, the second to the second value...
                      and so on.', [
        '@url' => 'https://developer.mozilla.org/en-US/docs/Web/CSS/linear-gradient',
      ]),
      '#default_value' => $settings['css_settings']['bg_image_color'],
    ];

    // The selector for the background property.
    $element['css_settings']['bg_image_x'] = [
      '#type' => 'textfield',
      '#title' => $this
        ->t('Horizontal Alignment'),
      '#description' => $this
        ->t('The horizontal alignment of the background image formatted as any valid css alignment.
                      [<a href="http://www.w3schools.com/css/pr_background-position.asp">
                      css property: background-position
                      </a>]'),
      '#default_value' => $settings['css_settings']['bg_image_x'],
    ];

    // The selector for the background property.
    $element['css_settings']['bg_image_y'] = [
      '#type' => 'textfield',
      '#title' => $this
        ->t('Vertical Alignment'),
      '#description' => $this
        ->t('The vertical alignment of the background image formatted as any valid css alignment.
                      [<a href="http://www.w3schools.com/css/pr_background-position.asp">
                      css property: background-position
                      </a>]'),
      '#default_value' => $settings['css_settings']['bg_image_y'],
    ];

    // The selector for the background property.
    $element['css_settings']['bg_image_attachment'] = [
      '#type' => 'radios',
      '#title' => $this
        ->t('Background Attachment'),
      '#description' => $this
        ->t('The attachment setting for the background image.
                      [<a href="http://www.w3schools.com/css/pr_background-attachment.asp">
                      css property: background-attachment
                      </a>]'),
      '#options' => [
        FALSE => $this
          ->t('Ignore'),
        'scroll' => 'Scroll',
        'fixed' => 'Fixed',
      ],
      '#default_value' => $settings['css_settings']['bg_image_attachment'],
    ];

    // The background-repeat property.
    $element['css_settings']['bg_image_repeat'] = [
      '#type' => 'radios',
      '#title' => $this
        ->t('Background Repeat'),
      '#description' => $this
        ->t('Define the repeat settings for the background image.
                      [<a href="http://www.w3schools.com/css/pr_background-repeat.asp">
                      css property: background-repeat
                      </a>]'),
      '#options' => [
        FALSE => $this
          ->t('Ignore'),
        'no-repeat' => $this
          ->t('No Repeat'),
        'repeat' => $this
          ->t('Tiled (repeat)'),
        'repeat-x' => $this
          ->t('Repeat Horizontally (repeat-x)'),
        'repeat-y' => $this
          ->t('Repeat Vertically (repeat-y)'),
      ],
      '#default_value' => $settings['css_settings']['bg_image_repeat'],
    ];

    // The background-size property.
    $element['css_settings']['bg_image_background_size'] = [
      '#type' => 'textfield',
      '#title' => $this
        ->t('Background Size'),
      '#description' => $this
        ->t('The size of the background (NOTE: CSS3 only. Useful for responsive designs)
                      [<a href="http://www.w3schools.com/cssref/css3_pr_background-size.asp">
                      css property: background-size
                      </a>]'),
      '#default_value' => $settings['css_settings']['bg_image_background_size'],
    ];

    // background-size:cover suppor for IE8.
    $element['css_settings']['bg_image_background_size_ie8'] = [
      '#type' => 'checkbox',
      '#title' => $this
        ->t('Add background-size:cover support for ie8'),
      '#description' => $this
        ->t('The background-size css property is only supported on browsers that support CSS3.
                      However, there is a workaround for IE using Internet Explorer\'s built-in filters
                      (http://msdn.microsoft.com/en-us/library/ms532969%28v=vs.85%29.aspx).
                      Check this box to add the filters to the css. Sometimes it works well, sometimes it doesn\'t.
                      Use at your own risk'),
      '#default_value' => $settings['css_settings']['bg_image_background_size_ie8'],
    ];

    // Add gradient to background-image.
    $element['css_settings']['bg_image_gradient'] = [
      '#type' => 'textfield',
      '#title' => $this
        ->t('Gradient'),
      '#description' => $this
        ->t('Apply this background image gradient css.
                  Example: linear-gradient(red, yellow)
                  [<a href="https://www.w3schools.com/css/css3_gradients.asp">Read about gradients</a>]'),
      '#default_value' => $settings['css_settings']['bg_image_gradient'],
    ];

    // The media query specifics.
    $element['css_settings']['bg_image_media_query'] = [
      '#type' => 'textfield',
      '#title' => $this
        ->t('Media Query'),
      '#description' => $this
        ->t('Apply this background image css using a media query. CSS3 Only. Useful for responsive designs.
                      Example: only screen and (min-width:481px) and (max-width:768px)
                      [<a href="http://www.w3.org/TR/css3-mediaqueries/">Read about media queries</a>]'),
      '#default_value' => $settings['css_settings']['bg_image_media_query'],
    ];
    $element['css_settings']['bg_image_important'] = [
      '#type' => 'checkbox',
      '#title' => $this
        ->t('Add "!important" to the background property.'),
      '#description' => $this
        ->t('This can be helpful to override any existing background image or color properties added by the theme.'),
      '#default_value' => $settings['css_settings']['bg_image_important'],
    ];
    $element['css_settings']['bg_image_path_format'] = [
      '#type' => 'select',
      '#title' => $this
        ->t('Image Path Format'),
      '#options' => [
        'absolute' => $this
          ->t('Absolute'),
        'relative' => $this
          ->t('Relative'),
      ],
      '#description' => $this
        ->t('Defaults to absolute URLs, however relative URLs maybe solve issues with mixed content errors on websites being served on HTTPS.'),
      '#default_value' => $settings['css_settings']['bg_image_path_format'],
    ];
    return $element;
  }

  /**
   * {@inheritdoc}
   */
  public function settingsSummary() {
    $summary = [];
    $settings = $this
      ->getSettings();
    $image_styles = image_style_options(FALSE);
    unset($image_styles['']);
    if (isset($settings['css_settings']['bg_image_selector'])) {
      $summary[] = $this
        ->t('CSS Selector: @selector', [
        '@selector' => $settings['css_settings']['bg_image_selector'],
      ]);
    }
    else {
      $summary[] = $this
        ->t('No selector');
    }
    if (isset($image_styles[$settings['image_style']])) {
      $summary[] = $this
        ->t('URL for image style: @style', [
        '@style' => $image_styles[$settings['image_style']],
      ]);
    }
    else {
      $summary[] = $this
        ->t('Original image style');
    }
    return $summary;
  }

  /**
   * {@inheritdoc}
   */
  public function viewElements(FieldItemListInterface $items, $langcode) {
    $elements = [];
    $settings = $this
      ->getSettings();
    $css_settings = $settings['css_settings'];

    // Replace views tokens.
    $selector = $css_settings['bg_image_selector'];
    $token_start = mb_strpos($selector, '{{');
    if ($token_start !== FALSE) {
      $token_length = mb_strpos($selector, '}}') - mb_strpos($selector, '{{') + 2;
      $token = mb_substr($selector, mb_strpos($selector, '{{'), $token_length);
      $cleaned_token = trim(str_replace([
        '{{',
        '}}',
      ], '', $token));
      $entity = $items
        ->getEntity();
      if ($entity->{$cleaned_token} && $entity->{$cleaned_token}->value) {
        $selector = str_replace($token, $entity->{$cleaned_token}->value, $selector);
        $css_settings['bg_image_selector'] = $selector;
      }
    }
    $image_style = $settings['image_style'] ? $settings['image_style'] : NULL;
    $path_format = $css_settings['bg_image_path_format'];
    $selectors = explode(\PHP_EOL, trim($css_settings['bg_image_selector']));
    $colors = explode(\PHP_EOL, trim($css_settings['bg_image_color']));

    // Filter out empty selectors.
    $selectors = array_map(static function ($value) {
      return trim($value, ',');
    }, $selectors);

    // Filter out empty colors.
    $colors = array_filter(array_map('trim', $colors));
    $files = $this
      ->getEntitiesToView($items, $langcode);

    // Early opt-out if the field is empty.
    if (empty($files)) {
      return $elements;
    }

    // Prepare token data in bg image css selector.
    $token_data = [
      'user' => \Drupal::currentUser(),
      $items
        ->getEntity()
        ->getEntityTypeId() => $items
        ->getEntity(),
    ];
    foreach ($selectors as &$selector) {
      $selector = \Drupal::token()
        ->replace($selector, $token_data);
    }

    // Need an empty element so views renderer will see something to render.
    $elements[0] = [];
    foreach ($files as $delta => $file) {
      $css_settings['bg_image_selector'] = $selectors[$delta % \count($selectors)];
      if ($colors) {
        $css_settings['bg_image_color'] = $colors[$delta % \count($colors)];
      }
      if ($image_style) {
        $style = $this->imageStyleStorage
          ->load($image_style);
        if (!$style) {
          throw new \Exception("Image style not found: {$image_style}");
        }
        $file_url = $style
          ->buildUrl($file
          ->getFileUri());
      }
      else {
        $file_url = file_create_url($file
          ->getFileUri());
      }
      $image_url = $path_format === 'absolute' ? $file_url : file_url_transform_relative($file_url);
      $elements['#attached']['css'] = [
        $this
          ->getBackgroundImageCss($image_url, $css_settings),
      ];
    }
    return $elements;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
AjaxHelperTrait::getRequestWrapperFormat protected function Gets the wrapper format of the current request.
AjaxHelperTrait::isAjax protected function Determines if the current request is via AJAX.
BgImageFormatter::$renderer protected property The renderer service.
BgImageFormatter::$request protected property The current request.
BgImageFormatter::create public static function Creates an instance of the plugin. Overrides ImageFormatter::create
BgImageFormatter::defaultSettings public static function Defines the default settings for this plugin. Overrides ImageFormatter::defaultSettings
BgImageFormatter::getBackgroundImageCss public function Function taken from the module 'bg_image'.
BgImageFormatter::settingsForm public function Returns a form to configure settings for the formatter. Overrides ImageFormatter::settingsForm 1
BgImageFormatter::settingsSummary public function Returns a short summary for the current formatter settings. Overrides ImageFormatter::settingsSummary 1
BgImageFormatter::viewElements public function Builds a renderable array for a field value. Overrides ImageFormatter::viewElements 1
BgImageFormatter::__construct public function BgImageFormatter constructor. Overrides ImageFormatter::__construct
DependencySerializationTrait::$_entityStorages protected property An array of entity type IDs keyed by the property name of their storages.
DependencySerializationTrait::$_serviceIds protected property An array of service IDs keyed by property name used for serialization.
DependencySerializationTrait::__sleep public function 1
DependencySerializationTrait::__wakeup public function 2
EntityReferenceFormatterBase::prepareView public function Loads the entities referenced in that field across all the entities being viewed. Overrides FormatterBase::prepareView
EntityReferenceFormatterBase::view public function Overrides FormatterBase::view
FileFormatterBase::checkAccess protected function Checks access to the given entity. Overrides EntityReferenceFormatterBase::checkAccess
FileFormatterBase::needsEntityLoad protected function Returns whether the entity referenced by an item needs to be loaded. Overrides EntityReferenceFormatterBase::needsEntityLoad 1
FormatterBase::$fieldDefinition protected property The field definition.
FormatterBase::$label protected property The label display setting.
FormatterBase::$settings protected property The formatter settings. Overrides PluginSettingsBase::$settings
FormatterBase::$viewMode protected property The view mode.
FormatterBase::getFieldSetting protected function Returns the value of a field setting.
FormatterBase::getFieldSettings protected function Returns the array of field settings.
FormatterBase::isApplicable public static function Returns if the formatter can be used for the provided field. Overrides FormatterInterface::isApplicable 14
ImageFormatter::$currentUser protected property The current user.
ImageFormatter::$imageStyleStorage protected property The image style entity storage.
ImageFormatter::calculateDependencies public function Calculates dependencies for the configured plugin. Overrides PluginSettingsBase::calculateDependencies
ImageFormatter::onDependencyRemoval public function Informs the plugin that some configuration it depends on will be deleted. Overrides PluginSettingsBase::onDependencyRemoval
ImageFormatterBase::getEntitiesToView protected function Returns the referenced entities for display. Overrides EntityReferenceFormatterBase::getEntitiesToView
MessengerTrait::$messenger protected property The messenger. 29
MessengerTrait::messenger public function Gets the messenger. 29
MessengerTrait::setMessenger public function Sets the messenger.
PluginBase::$configuration protected property Configuration information passed into the plugin. 1
PluginBase::$pluginDefinition protected property The plugin implementation definition. 1
PluginBase::$pluginId protected property The plugin_id.
PluginBase::DERIVATIVE_SEPARATOR constant A string which is used to separate base plugin IDs from the derivative ID.
PluginBase::getBaseId public function Gets the base_plugin_id of the plugin instance. Overrides DerivativeInspectionInterface::getBaseId
PluginBase::getDerivativeId public function Gets the derivative_id of the plugin instance. Overrides DerivativeInspectionInterface::getDerivativeId
PluginBase::getPluginDefinition public function Gets the definition of the plugin implementation. Overrides PluginInspectionInterface::getPluginDefinition 3
PluginBase::getPluginId public function Gets the plugin_id of the plugin instance. Overrides PluginInspectionInterface::getPluginId
PluginBase::isConfigurable public function Determines if the plugin is configurable.
PluginSettingsBase::$defaultSettingsMerged protected property Whether default settings have been merged into the current $settings.
PluginSettingsBase::$thirdPartySettings protected property The plugin settings injected by third party modules.
PluginSettingsBase::getSetting public function Returns the value of a setting, or its default value if absent. Overrides PluginSettingsInterface::getSetting
PluginSettingsBase::getSettings public function Returns the array of settings, including defaults for missing settings. Overrides PluginSettingsInterface::getSettings
PluginSettingsBase::getThirdPartyProviders public function Gets the list of third parties that store information. Overrides ThirdPartySettingsInterface::getThirdPartyProviders
PluginSettingsBase::getThirdPartySetting public function Gets the value of a third-party setting. Overrides ThirdPartySettingsInterface::getThirdPartySetting
PluginSettingsBase::getThirdPartySettings public function Gets all third-party settings of a given module. Overrides ThirdPartySettingsInterface::getThirdPartySettings
PluginSettingsBase::mergeDefaults protected function Merges default settings values into $settings.
PluginSettingsBase::setSetting public function Sets the value of a setting for the plugin. Overrides PluginSettingsInterface::setSetting
PluginSettingsBase::setSettings public function Sets the settings for the plugin. Overrides PluginSettingsInterface::setSettings
PluginSettingsBase::setThirdPartySetting public function Sets the value of a third-party setting. Overrides ThirdPartySettingsInterface::setThirdPartySetting
PluginSettingsBase::unsetThirdPartySetting public function Unsets a third-party setting. Overrides ThirdPartySettingsInterface::unsetThirdPartySetting
StringTranslationTrait::$stringTranslation protected property The string translation service. 1
StringTranslationTrait::formatPlural protected function Formats a string containing a count of items.
StringTranslationTrait::getNumberOfPlurals protected function Returns the number of plurals supported by a given language.
StringTranslationTrait::getStringTranslation protected function Gets the string translation service.
StringTranslationTrait::setStringTranslation public function Sets the string translation service to use. 2
StringTranslationTrait::t protected function Translates a string to the current language or to a given language.