class DeployAggregatorViews in Deploy - Content Staging 7.2
Same name and namespace in other branches
- 7.3 modules/deploy_aggregator_views/plugins/DeployAggregatorViews.inc \DeployAggregatorViews
Class for a deploy aggregator that aggregates entities using a View.
Hierarchy
- class \DeployAggregatorBase implements DeployAggregator
- class \DeployAggregatorViews
Expanded class hierarchy of DeployAggregatorViews
1 string reference to 'DeployAggregatorViews'
- deploy_aggregator_views_deploy_aggregators in modules/
deploy_aggregator_views/ deploy_aggregator_views.module - Implementation of hook_deploy_aggregators().
File
- modules/
deploy_aggregator_views/ plugins/ DeployAggregatorViews.inc, line 10 - Views based aggregator for deployment plan entities.
View source
class DeployAggregatorViews extends DeployAggregatorBase {
public $config = array();
/**
* Holds a reference to the plan object that initiated it.
*
* @var DeployPlan
*/
public $plan;
/**
* {@inheritdoc}
*/
public function __construct(DeployPlan $plan = NULL, array $config = array()) {
$defaults = array(
'debug' => FALSE,
'view_name' => '',
);
$this->config = array_merge($defaults, $config);
$this->plan = $plan;
}
/**
* Get aggregated entities.
*/
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;
}
/**
* {@inheritdoc}
*/
public function configForm(&$form_state) {
$form = array();
$options = array();
$views = views_get_enabled_views();
foreach ($views as $view_name => $view) {
$options[$view_name] = !empty($view->human_name) ? $view->human_name : $view->name;
}
$form['view_name'] = array(
'#type' => 'select',
'#title' => t('View'),
'#description' => t('Select the view that is going to provide this deployment plan with content.'),
'#options' => $options,
'#default_value' => $this->config['view_name'],
);
return $form;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
DeployAggregatorBase:: |
public | function | Returns a DeployIteratorIterator, which can iterate through recursive iterators | |
DeployAggregatorViews:: |
public | property | ||
DeployAggregatorViews:: |
public | property | Holds a reference to the plan object that initiated it. | |
DeployAggregatorViews:: |
public | function |
Defines the configuration form for the aggregator. Overrides DeployAggregatorBase:: |
|
DeployAggregatorViews:: |
public | function |
Get aggregated entities. Overrides DeployAggregatorBase:: |
|
DeployAggregatorViews:: |
public | function |
Constructor for a deploy aggregator. Overrides DeployAggregatorBase:: |