You are here

function lazy_post_update_add_prefernative_option in Lazy-load 8.3

Update lazy module configuration for the new "preferNative" option.

File

./lazy.post_update.php, line 11
Lazy module post updates.

Code

function lazy_post_update_add_prefernative_option() {
  $config = \Drupal::configFactory()
    ->getEditable('lazy.settings');

  // If it's already set use that value, otherwise set to false.
  $preferNative = (bool) ($config
    ->get('preferNative') !== NULL ? $config
    ->get('preferNative') : FALSE);
  $config
    ->set('preferNative', $preferNative)
    ->save(TRUE);
  return t('The new "preferNative" option is added, and set to %status. (Default: <em>false</em>)', [
    '%status' => $preferNative ? 'enabled' : 'disabled',
  ]);
}