You are here

public static function PWAController::pwa_get_cache_version in Progressive Web App 8

Same name and namespace in other branches
  1. 2.x src/Controller/PWAController.php \Drupal\pwa\Controller\PWAController::pwa_get_cache_version()

Returns current cache version.

Return value

string Cache version.

2 calls to PWAController::pwa_get_cache_version()
PWAController::pwa_serviceworker_file_data in src/Controller/PWAController.php
Replace the serviceworker file with variables from Drupal config.
pwa_page_attachments in ./pwa.module
Implements hook_page_attachments().

File

src/Controller/PWAController.php, line 249
Replace values in serviceworker.js

Class

PWAController
Default controller for the pwa module.

Namespace

Drupal\pwa\Controller

Code

public static function pwa_get_cache_version() {

  // Get module configuration.
  $config = \Drupal::config('pwa.config');

  // Look up module release from package info.
  $pwa_module_info = \Drupal::service('extension.list.module')
    ->getExtensionInfo('pwa');
  $pwa_module_version = $pwa_module_info['version'];

  // Packaging script will always provide the published module version. Checking
  // for NULL is only so maintainers have something predictable to test against.
  if ($pwa_module_version == NULL) {
    $pwa_module_version = '8.x-1.x-dev';
  }
  return $pwa_module_version . '-v' . ($config
    ->get('cache_version') ?: 1);
}