function Settings::setAll

Same name and namespace in other branches
  1. 11.x core/themes/admin/src/Settings.php \Drupal\admin\Settings::setAll()

Set user overrides.

Parameters

array $settings: The user specific theme settings.

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

File

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

Class

Settings
Service to handle overridden user settings.

Namespace

Drupal\admin

Code

public function setAll(array $settings, ?AccountInterface $account = NULL) : void {
  if (!$account || !$this->userData) {
    $account = $this->currentUser;
  }
  // All settings are deleted to remove legacy settings.
  $this->userData
    ->delete('admin', $account->id());
  $this->userData
    ->set('admin', $account->id(), 'enable_user_settings', TRUE);
  $this->userData
    ->set('admin', $account->id(), 'settings', $settings);
}

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