class DeployIterator in Deploy - Content Staging 7.2
Same name and namespace in other branches
- 7.3 includes/DeployIterator.inc \DeployIterator
Iterator class which does the heavy lifting for detecting dependencies.
Hierarchy
- class \EntityDependencyIterator implements \RecursiveIterator
- class \DeployIterator
Expanded class hierarchy of DeployIterator
1 string reference to 'DeployIterator'
- deploy_entity_dependency_iterator in ./
deploy.module - Implements hook_entity_dependency_iterator().
File
- includes/
DeployIterator.inc, line 10 - Deploy interator implementation.
View source
class DeployIterator extends EntityDependencyIterator {
/**
* Cache entity information.
*/
protected static $entity_info = array();
/**
* We override this method since we need to return our own iterator.
*
* @return DeployIterator
*/
public function getChildren() {
return new DeployIterator($this
->getChildrenEntities(), $this);
}
/**
* We override this method since we need to return UUID entities, with some
* extra hooks.
*
* @see http://www.odata.org/developers/protocols
*/
public function current() {
$current = current($this->entities);
// Load and cache the entity info.
if (!isset(self::$entity_info[$current['type']])) {
self::$entity_info[$current['type']] = entity_get_info($current['type']);
}
$uuids = entity_get_uuid_by_id($current['type'], array(
$current['id'],
));
$uuid = reset($uuids);
$conditions = array();
$unique_id = $current['id'];
if (!empty($current['revision_id']) && !empty(self::$entity_info[$current['type']]['entity keys']['revision uuid'])) {
$revision_key = self::$entity_info[$current['type']]['entity keys']['revision uuid'];
$revisions = entity_get_uuid_by_id($current['type'], array(
$current['revision_id'],
), TRUE);
$conditions[$revision_key] = reset($revisions);
$unique_id .= "-{$current['revision_id']}";
}
// Load the current entity with UUID.
$entities = entity_uuid_load($current['type'], array(
$uuid,
), $conditions);
$entity = reset($entities);
// Add necessary metadata to the entity.
$cause = FALSE;
if (!empty($this->causes[$current['type']][$current['id']])) {
$cause_type = $this->causes[$current['type']][$current['id']]['type'];
$cause_id = $this->causes[$current['type']][$current['id']]['id'];
$cause_uuids = entity_get_uuid_by_id($cause_type, array(
$cause_id,
));
$cause_uuid = reset($cause_uuids);
$cause = $cause_type . '/' . $cause_uuid;
}
$entity->__metadata = array(
'type' => $current['type'],
'uri' => $current['type'] . '/' . $uuid,
'cause' => $cause,
);
// Now mark this as traversed.
$this->traversed[$current['type']][$unique_id] = TRUE;
// Let other modules have their say.
drupal_alter('deploy_entity', $entity, $current['type']);
return $entity;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
DeployIterator:: |
protected static | property | Cache entity information. | |
DeployIterator:: |
public | function |
We override this method since we need to return UUID entities, with some
extra hooks. Overrides EntityDependencyIterator:: |
|
DeployIterator:: |
public | function |
We override this method since we need to return our own iterator. Overrides EntityDependencyIterator:: |
1 |
EntityDependencyIterator:: |
public | property | An array of belongings to the entity being parsed. | |
EntityDependencyIterator:: |
public | property | An array with information on the cause/reason why an entity exists in the tree. Basically, the cause for term A's existance in the tree, might be becasue node B depends on it. | |
EntityDependencyIterator:: |
public | property | Keeps track of entities that have already been checked for dependencies. | |
EntityDependencyIterator:: |
public | property | An array of dependencies to the entity being parsed. | |
EntityDependencyIterator:: |
public | property | The entities to be iterated over. | |
EntityDependencyIterator:: |
public | property | The entity ID of the entity currently being iterated over. | |
EntityDependencyIterator:: |
public | property | The entity type of the entity currently being iterated over. | |
EntityDependencyIterator:: |
public | property | Keeps track of entities that have already been traversed (output). | |
EntityDependencyIterator:: |
public | function | Helper method to get entity dependencies. | |
EntityDependencyIterator:: |
public | function | Returns TRUE if an iterator can be created for the current item in the entities array. | |
EntityDependencyIterator:: |
public | function | Returns the key of the current element. | |
EntityDependencyIterator:: |
public | function | Moves the current position to the next element. | |
EntityDependencyIterator:: |
public | function | Rewinds the Iterator to the first element. | |
EntityDependencyIterator:: |
public | function | Checks if current position is valid. | |
EntityDependencyIterator:: |
public | function | Constructor. |