You are here

function pwa_install in Progressive Web App 8

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

Implements hook_install().

File

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

Code

function pwa_install() {
  user_role_grant_permissions(RoleInterface::ANONYMOUS_ID, [
    'access pwa',
  ]);

  // Set the site name dynamically.
  $site_name = \Drupal::config('system.site')
    ->get('name');
  $output = [
    'site_name' => $site_name,
    'short_name' => substr($site_name, 0, 25),
  ];
  $config = \Drupal::configFactory()
    ->getEditable('pwa.config');
  foreach ($output as $key => $value) {
    $config
      ->set($key, $value);
  }
  $config
    ->save();
}