function Settings::get

Same name in this branch
  1. 11.x core/lib/Drupal/Core/Site/Settings.php \Drupal\Core\Site\Settings::get()
Same name and namespace in other branches
  1. 10 core/lib/Drupal/Core/Site/Settings.php \Drupal\Core\Site\Settings::get()
  2. 9 core/lib/Drupal/Core/Site/Settings.php \Drupal\Core\Site\Settings::get()
  3. 8.9.x core/lib/Drupal/Core/Site/Settings.php \Drupal\Core\Site\Settings::get()
  4. main core/lib/Drupal/Core/Site/Settings.php \Drupal\Core\Site\Settings::get()
  5. main core/themes/admin/src/Settings.php \Drupal\admin\Settings::get()

Get the setting for the current user.

Parameters

string $name: The name of the setting.

\Drupal\Core\Session\AccountInterface|null $account: The account object. Current user if NULL.

Return value

array|bool|mixed|null The current value.

2 calls to Settings::get()
Settings::getSettingsForm in core/themes/admin/src/Settings.php
Build the settings form for the theme.
Settings::overridden in core/themes/admin/src/Settings.php
Check if the user setting overrides the global setting.

File

core/themes/admin/src/Settings.php, line 86

Class

Settings
Service to handle overridden user settings.

Namespace

Drupal\admin

Code

public function get(string $name, ?AccountInterface $account = NULL) : mixed {
  $value = NULL;
  if (!$account) {
    $account = $this->currentUser;
  }
  if ($this->userOverrideEnabled($account)) {
    $settings = $this->userData
      ->get('admin', $account->id(), 'settings');
    $value = $settings[$name] ?? $this->userData
      ->get('admin', $account->id(), $name);
  }
  if (is_null($value)) {
    $admin_theme = $this->getAdminTheme();
    $value = $this->themeSettingsProvider
      ->getSetting($name, $admin_theme);
  }
  return $value;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.