You are here

function _services_resource_upgrade in Services 7.3

Same name and namespace in other branches
  1. 6.3 services.resource_build.inc \_services_resource_upgrade()

Upgrades old resource definition to the newer format.

Parameters

int $from: The API version that the resource was written for.

array $resources: The resource definitions.

array $version_info: Optional. The version info array as returned from services_resource_api_version_info().

Return value

void

1 call to _services_resource_upgrade()
_services_build_resources in includes/services.resource_build.inc
Builds the resource definition array for a endpoint.

File

includes/services.resource_build.inc, line 119
Contains functions necessary for building the resource definitions. This is only needed the first time a the resources for a endpoint are fetched, or when the cache has been cleared.

Code

function _services_resource_upgrade($from, &$resources, $version_info = NULL) {
  module_load_include('inc', 'services', 'includes/services.resource_update');

  // Get version info if needed.
  if ($version_info == NULL) {
    $version_info = services_resource_api_version_info();
  }

  // Run upgrades.
  foreach ($version_info['versions'] as $update) {
    if ($update > $from) {
      call_user_func_array("services_resource_api_update_{$update}", array(
        &$resources,
      ));
    }
  }
}