You are here

function node_gallery_api_get_relationships in Node Gallery 7

Get Node Gallery Relationships.

Parameters

int $gallery_nid: Gallery NID

int $item_nid: Item NID

int $id: Relationship entity ID

bool $ids_only: If true, skip loading the entities.

Return value

array Array of Node Gallery relationships matching parameters.

15 calls to node_gallery_api_get_relationships()
NodeGalleryBehaviorHandler::galleriesGetDiff in plugins/entityreference/behavior/NodeGalleryBehaviorHandler.class.php
Get the difference in group audience for a saved field.
NodeGalleryBehaviorHandler::load in plugins/entityreference/behavior/NodeGalleryBehaviorHandler.class.php
Act on loading entity reference fields of entities.
node_gallery_api_file_view in ./node_gallery_api.module
Implements hook_file_view().
node_gallery_api_node_insert in ./node_gallery_api.module
Implements hook_node_insert().
node_gallery_api_node_update in ./node_gallery_api.module
Implements hook_node_update().

... See full list

File

./node_gallery_api.inc, line 23
Node Gallery API function

Code

function node_gallery_api_get_relationships($gallery_nid = NULL, $item_nid = NULL, $id = NULL, $ids_only = FALSE) {
  $query = new EntityFieldQuery();
  $query
    ->entityCondition('entity_type', 'node_gallery_relationship');
  if (!empty($item_nid)) {
    $query
      ->propertyCondition('nid', $item_nid);
  }
  if (!empty($gallery_nid)) {
    $query
      ->propertyCondition('ngid', $gallery_nid);
  }
  if (!empty($id)) {
    $query
      ->propertyCondition('id', (int) $id);
  }
  $relationships = $query
    ->execute();
  if (!empty($relationships['node_gallery_relationship'])) {
    $relationships = array_keys($relationships['node_gallery_relationship']);
    if ($ids_only) {
      return $relationships;
    }
    return entity_load('node_gallery_relationship', $relationships);
  }
  return array();
}