You are here

WebformPluginSettingsTrait.php in Webform 8.5

Same filename and directory in other branches
  1. 6.x src/Plugin/WebformPluginSettingsTrait.php

File

src/Plugin/WebformPluginSettingsTrait.php
View source
<?php

namespace Drupal\webform\Plugin;


/**
 * Provides a plugin settings trait.
 */
trait WebformPluginSettingsTrait {

  /**
   * {@inheritdoc}
   */
  public function getSettings() {
    $configuration = $this
      ->getConfiguration();
    return $configuration['settings'];
  }

  /**
   * {@inheritdoc}
   */
  public function setSettings(array $settings) {
    $configuration = $this
      ->getConfiguration();
    $configuration['settings'] = $settings + $configuration['settings'];
    $this
      ->setConfiguration($configuration);
    return $this;
  }

  /**
   * {@inheritdoc}
   */
  public function getSetting($key) {
    $configuration = $this
      ->getConfiguration();
    return isset($configuration['settings'][$key]) ? $configuration['settings'][$key] : NULL;
  }

  /**
   * {@inheritdoc}
   */
  public function setSetting($key, $value) {
    $configuration = $this
      ->getConfiguration();
    $configuration['settings'][$key] = $value;
    return $this
      ->setConfiguration($configuration);
  }

}

Traits

Namesort descending Description
WebformPluginSettingsTrait Provides a plugin settings trait.