You are here

function pwa_install in Progressive Web App 7

Same name and namespace in other branches
  1. 8 pwa.install \pwa_install()
  2. 7.2 pwa.install \pwa_install()
  3. 2.x pwa.install \pwa_install()

Implements hook_install().

File

./pwa.install, line 48

Code

function pwa_install() {
  $directory = file_default_scheme() . '://pwa';
  file_prepare_directory($directory, FILE_CREATE_DIRECTORY | FILE_MODIFY_PERMISSIONS);
  variable_set('pwa_sw_cache_exclude', implode("\n", PWA_SW_CACHE_EXCLUDE));
  variable_set('pwa_sw_cache_urls', implode("\n", [
    '/',
    '/offline',
    variable_get('pwa_start_url', ''),
  ]));
  pwa_flush_caches();

  // By default give permissions to anonymous users.
  //
  // @TODO: set a status message prompting admins to enable functionality for
  //        other roles themselves.
  //
  user_role_grant_permissions(DRUPAL_ANONYMOUS_RID, [
    'access pwa',
  ]);
}