You are here

function pwa_update_8001 in Progressive Web App 8

Same name and namespace in other branches
  1. 2.x pwa.install \pwa_update_8001()

Set the default offline_page variable.

File

./pwa.install, line 81
PWA install hooks.

Code

function pwa_update_8001(&$sandbox) {

  // Set the offline page path to the default value.
  $config_factory = \Drupal::configFactory();
  $config = $config_factory
    ->getEditable('pwa.config');
  $config
    ->set('offline_page', '/offline')
    ->save(TRUE);

  // Remove the offline page path from the URL's to cache. It will be added
  // automatically in PWAController::pwa_serviceworker_file_data().
  $cache_urls = array_diff(pwa_str_to_list($config
    ->get('urls_to_cache')), [
    '/offline',
  ]);
  $config
    ->set('urls_to_cache', implode("\r\n", $cache_urls))
    ->save(TRUE);
}