function opening_hours_instance_id_api_page in Opening hours 7
Same name and namespace in other branches
- 6 includes/opening_hours.pages.inc \opening_hours_instance_id_api_page()
The CRUD API for a specific instance ID.
1 string reference to 'opening_hours_instance_id_api_page'
- opening_hours_menu in ./
opening_hours.module - Implements hook_menu().
File
- includes/
opening_hours.pages.inc, line 90 - Page callbacks for the opening hours module.
Code
function opening_hours_instance_id_api_page($instance) {
$output = array();
switch ($_SERVER['REQUEST_METHOD']) {
case 'GET':
$output[] = $instance;
break;
case 'PUT':
$updated_instance = _opening_hours_get_instance_from_request();
// We can hardly save an instance that doesn't have the required data.
if (!$updated_instance) {
header('HTTP/1.1 400 Bad Request');
exit('Required fields were missing or invalid.');
}
// Check that instance_id matches up.
if ($updated_instance->instance_id != $instance->instance_id) {
header('HTTP/1.1 400 Bad Request');
exit('Instance ID mismatch.');
}
module_invoke_all('opening_hours_presave', $updated_instance, $instance);
$output[] = _opening_hours_instance_update($updated_instance, $instance);
break;
case 'DELETE':
module_invoke_all('opening_hours_delete', $instance);
_opening_hours_instance_delete($instance);
break;
}
return drupal_json_output($output);
}