You are here

function _restful_get_data_from_menu_status in RESTful 7.2

Convert a menu status response to a valid JSON.

Parameters

int $var: The integer value of the menu status, passed by reference.

1 call to _restful_get_data_from_menu_status()
restful_delivery in ./restful.module
Returns data in JSON format.

File

./restful.module, line 385

Code

function _restful_get_data_from_menu_status(&$var) {
  switch ($var) {
    case MENU_NOT_FOUND:
      $class_name = '\\Drupal\\restful\\Exception\\NotFoundException';
      $message = 'Invalid URL path.';
      break;
    case MENU_ACCESS_DENIED:
      $class_name = '\\Drupal\\restful\\Exception\\ForbiddenException';
      $message = 'Access denied.';
      break;
    case MENU_SITE_OFFLINE:
      $class_name = '\\Drupal\\restful\\Exception\\ServiceUnavailableException';
      $message = 'Site is offline.';
      break;
    default:
      $class_name = '\\Drupal\\restful\\Exception\\RestfulException';
      $message = 'Unknown exception';
  }
  $var = _restful_build_http_api_error(new $class_name($message));
}