function _pwa_check_page_callback_result in Progressive Web App 7.2
Handle access permission returns.
Parameters
$page_callback_result:
Return value
bool
3 calls to _pwa_check_page_callback_result()
- pwa_deliver_json in ./
pwa.module - Deliver a json response, don't involve the theme layer for a 'quick' check.
- pwa_deliver_manifest_file in ./
pwa.module - Set the correct mime type for manifest file.
- pwa_deliver_serviceworker_file in ./
pwa.module - Deliver the JS for the service worker.
File
- ./
pwa.module, line 551
Code
function _pwa_check_page_callback_result($page_callback_result) {
// Menu status constants are integers; page content is a string or array.
if (is_int($page_callback_result)) {
switch ($page_callback_result) {
case MENU_ACCESS_DENIED:
// Print a 403 page. This will make the Phone home check
// UNINSTALL the serviceworker.
drupal_add_http_header('Content-Type', 'application/javascript');
drupal_add_http_header('Status', '403 Forbidden');
print drupal_json_encode([
'pwa' => 'access denied',
]);
return FALSE;
break;
case MENU_NOT_FOUND:
// Print a 404 page. This will make the Phone home check
// UNINSTALL the serviceworker.
drupal_add_http_header('Content-Type', 'application/javascript');
drupal_add_http_header('Status', '404 Not Found');
print drupal_json_encode([
'pwa' => 'not found',
]);
return FALSE;
break;
case MENU_SITE_OFFLINE:
// Print a 503 page. This is a temporary error, the serviceworker will
// NOT be uninstalled.
drupal_add_http_header('Content-Type', 'application/javascript');
drupal_add_http_header('Status', '503 Service unavailable');
print drupal_json_encode([
'pwa' => 'site under maintenance',
]);
return FALSE;
break;
}
}
return TRUE;
}