You are here

function SearchByPageService::setSetting in Search by Page 8

Sets a setting for Search by Page or a sub-module. [D8 ported] search_by_page_setting_set() in .module file.

This is like the Drupal \Drupal::state()->set() function, except that it is environment-aware.

Parameters

$name: Name of the setting.

$environment: ID of the environment.

$value: Value to set.

See also

search_by_page_setting_get()

File

src/Services/SearchByPageService.php, line 116
Search By Page Service and helper methods.

Class

SearchByPageService

Namespace

Drupal\search_by_page\Services

Code

function setSetting($name, $environment, $value) {
  $stuff = \Drupal::state()
    ->get('search_by_page_settings', []);
  if (!isset($stuff[$environment])) {
    $stuff[$environment] = [];
  }
  $stuff[$environment][$name] = $value;
  \Drupal::state()
    ->set('search_by_page_settings', $stuff);
}