You are here

public function BackgroundImageForm::getSettingValue in Background Image 8

Same name and namespace in other branches
  1. 2.x src/Form/BackgroundImageForm.php \Drupal\background_image\Form\BackgroundImageForm::getSettingValue()
  2. 2.0.x src/Form/BackgroundImageForm.php \Drupal\background_image\Form\BackgroundImageForm::getSettingValue()

Retrieves a setting value from the form state values or default values.

Parameters

string|string[] $name: The name of the setting value to retrieve.

mixed $default: The default value.

Return value

mixed|null The setting value or NULL if not set.

3 calls to BackgroundImageForm::getSettingValue()
BackgroundImageForm::buildSetting in src/Form/BackgroundImageForm.php
Builds a setting element.
BackgroundImageForm::buildSettings in src/Form/BackgroundImageForm.php
Builds the "Settings" group.
BackgroundImageForm::getSettingValues in src/Form/BackgroundImageForm.php
Retrieves all the setting values.

File

src/Form/BackgroundImageForm.php, line 563

Class

BackgroundImageForm

Namespace

Drupal\background_image\Form

Code

public function getSettingValue($name, $default = NULL) {
  if (!isset($default)) {
    $default = $this->backgroundImage
      ->getSetting($name, $this->parent ? $this->parent
      ->getSetting($name) : NULL);
  }
  $parts = explode('.', $name);
  $first = array_shift($parts);
  $toggle = (int) $this
    ->getSubformValue(array_merge([
    'settings',
  ], (array) $first, [
    'toggle',
  ]), BackgroundImageInterface::NORMAL);
  if ($toggle === BackgroundImageInterface::INHERIT) {
    return $this->parent ? $this->parent
      ->getSetting($name) : NULL;
  }
  return $this
    ->getSubformValue(array_merge([
    'settings',
  ], (array) $first, [
    'container',
    'value',
  ], $parts), $default);
}