You are here

function deploy_find_entity in Deploy - Content Staging 7.3

Looks up which plans an entity is present in.

Parameters

string $entity_type: The machine name of the entity type.

int $entity_id: The id for the entity.

string $exclude: The machine of a plan to exclude from the look up. Ignored if NULL.

int $revision_id: The revision id to use for the lookup. All revisions are used if NULL.

Return value

array List of plans the entity was found in.

2 calls to deploy_find_entity()
deploy_manager_entity_use_latest_revision in ./deploy.rules.inc
Action callback for the "Use Latest Revision of Entity" action.
deploy_views_handler_related_plans_field::render in includes/views/handler_related_plans_field.inc
Render the field.

File

./deploy.module, line 719
Deploy module functions.

Code

function deploy_find_entity($entity_type, $entity_id, $exclude = NULL, $revision_id = NULL) {
  $query = db_select('deploy_manager_entities', 'dme')
    ->fields('dme', [
    'plan_name',
  ])
    ->condition('entity_type', $entity_type)
    ->condition('entity_id', $entity_id)
    ->groupBy('plan_name');
  $query
    ->addExpression('MAX(revision_id)', 'max_rev_id');
  if ($exclude) {
    $query
      ->condition('plan_name', $exclude, '!=');
  }
  if ($revision_id) {
    $query
      ->condition('revision_id', $revision_id);
  }
  return $query
    ->execute()
    ->fetchAllKeyed();
}