You are here

public function FlexiformController::attachLoad in Flexiform 7

Overrides EntityAPIController::attachLoad().

Overrides EntityAPIControllerExportable::attachLoad

File

./flexiform.entity.inc, line 178
flexiform.entity.inc

Class

FlexiformController
The Controller for FlexiformSubmission entities

Code

public function attachLoad(&$queried_entities, $revision_id = FALSE) {
  $ids = array_keys($queried_entities);
  $tags = array();
  $result = db_select('flexiform_tags')
    ->fields('flexiform_tags', array(
    'id',
    'tag',
  ))
    ->condition('id', $ids, 'IN')
    ->execute();
  foreach ($result as $row) {
    $tags[$row->id][] = $row->tag;
  }
  foreach ($queried_entities as $entity_id => &$entity) {
    $entity->tags = !empty($tags[$entity_id]) ? $tags[$entity_id] : array();
  }
}