function RulesEntityController::attachLoad
Overridden.
See also
DrupalDefaultEntityController::attachLoad()
File
-
includes/
rules.core.inc, line 34
Class
- RulesEntityController
- Make sure loaded rule configs are instantiated right.
Code
protected function attachLoad(&$queried_entities, $revision_id = FALSE) {
// Retrieve stdClass records and store them as rules objects in 'data'.
$ids = array_keys($queried_entities);
$result = db_select('rules_tags')->fields('rules_tags', array(
'id',
'tag',
))
->condition('id', $ids, 'IN')
->execute();
foreach ($result as $row) {
$tags[$row->id][] = $row->tag;
}
$result = db_select('rules_dependencies')->fields('rules_dependencies', array(
'id',
'module',
))
->condition('id', $ids, 'IN')
->execute();
foreach ($result as $row) {
$modules[$row->id][] = $row->module;
}
$entities = array();
foreach ($queried_entities as $record) {
$entity = $record->data;
// Set the values of the other columns.
foreach ($this->entityInfo['schema_fields_sql']['base table'] as $field) {
$entity->{$field} = $record->{$field};
}
unset($entity->data, $entity->plugin);
// Add any tags or dependencies.
$entity->dependencies = isset($modules[$entity->id]) ? $modules[$entity->id] : array();
$entity->tags = isset($tags[$entity->id]) ? $tags[$entity->id] : array();
$entities[$entity->id] = $entity;
}
$queried_entities = $entities;
parent::attachLoad($queried_entities, $revision_id);
}