You are here

function system_update_8013 in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/system/system.install \system_update_8013()

Enable automated cron module and move the config into it.

File

core/modules/system/system.install, line 1813
Install, update and uninstall functions for the system module.

Code

function system_update_8013() {
  $config_factory = \Drupal::configFactory();
  $system_cron_config = $config_factory
    ->getEditable('system.cron');
  if ($autorun = $system_cron_config
    ->get('threshold.autorun')) {

    // Install 'automated_cron' module.
    \Drupal::service('module_installer')
      ->install([
      'automated_cron',
    ], FALSE);

    // Copy 'autorun' value into the new module's 'interval' setting.
    $config_factory
      ->getEditable('automated_cron.settings')
      ->set('interval', $autorun)
      ->save(TRUE);
  }

  // Remove the 'autorun' key in system module config.
  $system_cron_config
    ->clear('threshold.autorun')
    ->save(TRUE);
}