You are here

function pwa_webpush_menu in Progressive Web App 7.2

Implements hook_menu().

File

modules/pwa_webpush/pwa_webpush.module, line 42

Code

function pwa_webpush_menu() {
  $items = [];

  // Callback to save the subscription URL to the DB.
  $items['pwa/webpush/subscription/%'] = [
    'title' => t('Manage webpush subscription'),
    'page callback' => 'pwa_webpush_register',
    'page arguments' => [
      3,
    ],
    'access callback' => '_pwa_webpush_save_access',
    'access arguments' => [
      'access pwa webpush',
      [
        'POST',
        'DELETE',
      ],
    ],
    'delivery callback' => 'pwa_deliver_json',
    'file' => 'pwa_webpush.pages.inc',
    'type' => MENU_CALLBACK,
  ];

  // Admin settings to set VAPID informations.
  $items['admin/config/pwa/notification'] = [
    'title' => t('Push notification'),
    'description' => t('Configure Web Push notification settings.'),
    'page callback' => 'drupal_get_form',
    'page arguments' => [
      'pwa_webpush_admin_configuration',
    ],
    'access arguments' => [
      'administer pwa webpush',
    ],
    'file' => 'pwa_webpush.admin.inc',
    'type' => MENU_NORMAL_ITEM,
  ];
  $items['admin/config/pwa/notification/pushapi'] = [
    'title' => t('Push API'),
    'type' => MENU_DEFAULT_LOCAL_TASK,
    'weight' => -1,
  ] + $items['admin/config/pwa/notification'];
  $items['admin/config/pwa/notification/pushapi/test'] = [
    'title' => t('Send test notification'),
    'description' => t('Test sending a single push notification.'),
    'page arguments' => [
      'pwa_webpush_send_notification',
    ],
    'type' => MENU_LOCAL_ACTION,
    'weight' => 1,
  ] + $items['admin/config/pwa/notification'];

  // Add a shortcut to send a test notification on the subscription list page.
  $items['admin/config/pwa/notification/subscriptions/test'] = [
    'page callback' => 'drupal_goto',
    'page arguments' => [
      'admin/config/pwa/notification/pushapi/test',
      [
        'query' => [
          'destination' => 'admin/config/pwa/notification/subscriptions',
        ],
      ],
    ],
  ] + $items['admin/config/pwa/notification/pushapi/test'];
  return $items;
}