You are here

public function DeployAggregatorViews::getEntities in Deploy - Content Staging 7.3

Same name and namespace in other branches
  1. 7.2 modules/deploy_aggregator_views/plugins/DeployAggregatorViews.inc \DeployAggregatorViews::getEntities()

Get aggregated entities.

Overrides DeployAggregatorBase::getEntities

File

modules/deploy_aggregator_views/plugins/DeployAggregatorViews.inc, line 36
Views based aggregator for deployment plan entities.

Class

DeployAggregatorViews
Class for a deploy aggregator that aggregates entities using a View.

Code

public function getEntities() {
  $view = views_get_view($this->config['view_name'], 'default');
  $table_data = views_fetch_data($view->base_table);
  $entity_type = $table_data['table']['entity type'];
  $entity_id_field = $table_data['table']['base']['field'];
  $view_results = views_get_view_result($view->name, 'default');
  $entities = array();
  foreach ($view_results as $view_result) {
    $entity_info = entity_get_info($entity_type);
    $revision_key = $entity_info['entity keys']['revision'];
    $entity_id = $view_result->{$entity_id_field};
    $entity = entity_load($entity_type, array(
      $entity_id,
    ));
    $entities[] = array(
      'type' => $entity_type,
      'id' => $entity_id,
      'revision_id' => $entity[$entity_id]->{$revision_key},
    );
  }
  return $entities;
}