You are here

public function Translator::getSetting in Translation Management Tool 8

Retrieves a setting value from the translator settings.

Pulls the default values (if defined) from the plugin controller.

Parameters

string|array $name: The name of the setting, an array with multiple keys for nested settings.

Return value

string The setting value or $default if the setting value is not set. Returns NULL if the setting does not exist at all.

Overrides TranslatorInterface::getSetting

File

src/Entity/Translator.php, line 178

Class

Translator
Entity class for the tmgmt_translator entity.

Namespace

Drupal\tmgmt\Entity

Code

public function getSetting($name) {
  if (is_array($name)) {
    if (NestedArray::keyExists($this->settings, $name)) {
      return NestedArray::getValue($this->settings, $name);
    }
    elseif ($plugin = $this
      ->getPlugin()) {
      $defaults = $plugin
        ->defaultSettings();
      return NestedArray::getValue($defaults, $name);
    }
  }
  else {
    if (isset($this->settings[$name])) {
      return $this->settings[$name];
    }
    elseif ($plugin = $this
      ->getPlugin()) {
      $defaults = $plugin
        ->defaultSettings();
      if (isset($defaults[$name])) {
        return $defaults[$name];
      }
    }
  }
}