You are here

function clients_resource_get_for_component in Web Service Clients 7.3

Get the resource for a given component.

Eg, load the resource for the remote block with delta $delta.

Parameters

$resource_type: The resource type.

$component_name: The name of the component the resource is needed for.

Return value

A resource handler entity, or NULL if nothing is found.

1 call to clients_resource_get_for_component()
clients_resource_remote_views_block_block_view in resources/clients_resource_remote_views_block/clients_resource_remote_views_block.module
Implements hook_block_view().

File

./clients.module, line 24
Clients module provides a UI, storage, and an API for handling connections to remote webservices, including those provided by Services module on other Drupal sites.

Code

function clients_resource_get_for_component($resource_type, $component_name) {
  $result = db_query("SELECT name FROM {clients_resource} WHERE type = :type AND component = :component", array(
    ':type' => $resource_type,
    ':component' => $component_name,
  ));
  $name = $result
    ->fetchField();

  // During _entity_defaults_rebuild() it's possible for the resource to not
  // yet exist.
  if (!empty($name)) {
    return clients_resource_load($name);
  }
}