You are here

function services_endpoint_save in Services 7.3

Same name and namespace in other branches
  1. 6.3 services.module \services_endpoint_save()

Saves an endpoint in the database.

Return value

void

12 calls to services_endpoint_save()
ServicesAliasTests::setUp in tests/functional/ServicesAliasTests.test
Sets up a Drupal site for running functional and integration tests.
ServicesArgumentsTestCase::saveNewEndpoint in tests/functional/ServicesArgumentsTests.test
ServicesParserTests::setUp in tests/functional/ServicesParserTests.test
Sets up a Drupal site for running functional and integration tests.
ServicesResourceDisabledTest::saveNewEndpoint in tests/functional/ServicesResourceDisabledTests.test
Save a new endpoint without any resources enabled. This is a method from ServicesWebTestCase that has been modified.
ServicesWebTestCase::saveNewEndpoint in tests/services.test

... See full list

File

./services.module, line 447
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_include('export');
  ctools_export_crud_save('services_endpoint', $endpoint);
  ctools_export_load_object_reset('services_endpoint');
  menu_rebuild();
  cache_clear_all('services:' . $endpoint->name . ':', 'cache', TRUE);
}