You are here

function pwa_menu in Progressive Web App 7

Same name and namespace in other branches
  1. 7.2 pwa.module \pwa_menu()

Implements hook_menu().

File

./pwa.module, line 28

Code

function pwa_menu() {
  $items = [];
  $items['pwa/serviceworker/js'] = [
    'page callback' => 'pwa_serviceworker_file_data',
    'access arguments' => [
      'access pwa',
    ],
    'delivery callback' => 'pwa_deliver_js_file',
    'file' => 'pwa.pages.inc',
    'type' => MENU_CALLBACK,
  ];
  $items['offline'] = [
    'page callback' => 'pwa_offline_page',
    'access arguments' => [
      'access pwa',
    ],
    'file' => 'pwa.pages.inc',
    'type' => MENU_CALLBACK,
  ];
  $items[PWA_MODULE_ACTIVE_ROUTE] = [
    'page callback' => 'pwa_module_active',
    'access arguments' => [
      'access pwa',
    ],
    'file' => 'pwa.pages.inc',
    'type' => MENU_CALLBACK,
  ];

  // Admin settings for manifest.json
  $items['admin/config/system/pwa/manifest'] = [
    'title' => t('Add to Homescreen'),
    'description' => 'Control how your website appears on mobile devices when used as a PWA.',
    'page callback' => 'drupal_get_form',
    'page arguments' => [
      'pwa_admin_configuration_manifest',
    ],
    'access arguments' => [
      'administer pwa',
    ],
    'file' => 'pwa.admin.inc',
    'type' => MENU_DEFAULT_LOCAL_TASK,
  ];

  // Admin settings to control how SW is loaded and cached.
  $items['admin/config/system/pwa/serviceworker'] = [
    'title' => 'Service Worker',
    'description' => 'Technical configuration for PWA Service Worker.',
    'page callback' => 'drupal_get_form',
    'page arguments' => [
      'pwa_admin_configuration_sw',
    ],
    'access arguments' => [
      'administer pwa',
    ],
    'file' => 'pwa.admin.inc',
    'type' => MENU_LOCAL_TASK,
  ];

  // Specify manifest settings as default landing page when using system nav.
  $items['admin/config/system/pwa'] = [
    'title' => t('Progressive Web App'),
    'description' => 'Control how your website appears on mobile devices when used as a PWA.',
    'page callback' => 'drupal_get_form',
    'page arguments' => [
      'pwa_admin_configuration_manifest',
    ],
    'access arguments' => [
      'administer pwa',
    ],
    'file' => 'pwa.admin.inc',
    'type' => MENU_NORMAL_ITEM,
  ];
  return $items;
}