You are here

function slickgrid_callback in Slickgrid 6

Same name and namespace in other branches
  1. 7 includes/slickgrid.callbacks.inc \slickgrid_callback()

hook_menu callback; Universal callback - builds function name and returns error = true

1 string reference to 'slickgrid_callback'
slickgrid_menu in ./slickgrid.module
Implementation of hook_menu().

File

./slickgrid.callbacks.inc, line 7

Code

function slickgrid_callback($op) {
  $func = 'slickgrid_callback_' . $op;

  // Basic required json
  $json = array(
    'status' => TRUE,
    'op' => $op,
  );

  // The callback can append extra json
  if (is_array($additonal_json = $func())) {
    $json += $additonal_json;
  }

  // Add any drupal messages that have been created
  foreach (drupal_get_messages() as $type => $messages) {
    foreach ($messages as $message) {
      if ($type == 'error') {
        $json['error'] = true;
      }
      $json['messages'][] = array(
        'type' => $type,
        'message' => $message,
      );
    }
  }

  // Return the json
  slickgrid_json($json);
}