function services_endpoint_save in Services 6.3
Same name and namespace in other branches
- 7.3 services.module \services_endpoint_save()
Saves an endpoint in the database.
Return value
void
7 calls to services_endpoint_save()
- ServicesEndpointTests::saveNewEndpoint in tests/functional/ ServicesEndpointTests.test 
- ServicesParserTests::setUp in tests/functional/ ServicesParserTests.test 
- Implementation of setUp().
- ServicesWebTestCase::saveNewEndpoint in tests/functional/ ServicesWebTestCase.php 
- services_ctools_export_ui_form_submit in plugins/export_ui/ services_ctools_export_ui.inc 
- Submit handler for endpoint.
- services_edit_form_endpoint_authentication_submit in plugins/export_ui/ services_ctools_export_ui.class.php 
File
- ./services.module, line 229 
- Provides a generic but powerful API for web services.
Code
function services_endpoint_save($endpoint) {
  if (is_array($endpoint) && isset($endpoint['build_info'])) {
    $endpoint = $endpoint['build_info']['args'][0];
  }
  // Set a default of an array if the value is not present.
  foreach (array(
    'server_settings',
    'resources',
    'authentication',
  ) as $endpoint_field) {
    if (empty($endpoint->{$endpoint_field})) {
      $endpoint->{$endpoint_field} = array();
    }
  }
  ctools_export_crud_save('services_endpoint', $endpoint);
  ctools_export_load_object_reset('services_endpoint');
  menu_rebuild();
  cache_clear_all('services:' . $endpoint->name . ':', 'cache', TRUE);
}