public function MultifieldEntityController::load in Multifield 7
Same name and namespace in other branches
- 7.2 MultifieldEntityController.php \MultifieldEntityController::load()
Implements DrupalEntityControllerInterface::load().
Overrides DrupalDefaultEntityController::load
File
- ./
MultifieldEntityController.php, line 4
Class
Code
public function load($ids = array(), $conditions = array()) {
if (!empty($conditions)) {
throw new InvalidArgumentException('MultifieldEntityController does not support entity_load() using conditions.');
}
$entities = array();
// Create a new variable which is either a prepared version of the $ids
// array for later comparison with the entity cache, or FALSE if no $ids
// were passed. The $ids array is reduced as items are loaded from cache,
// and we need to know if it's empty for this reason to avoid querying the
// database when all requested entities are loaded from cache.
$passed_ids = !empty($ids) ? array_flip($ids) : FALSE;
// Try to load entities from the static cache, if the entity type supports
// static caching.
if ($this->cache) {
$entities += $this
->cacheGet($ids, $conditions);
// If any entities were loaded, remove them from the ids still to load.
if ($passed_ids) {
$ids = array_keys(array_diff_key($passed_ids, $entities));
}
}
// Load any remaining entities from the database. This is the case if $ids
// is set to FALSE (so we load all entities), if there are any ids left to
// load, if loading a revision, or if $conditions was passed without $ids.
if ($ids === FALSE || $ids) {
$entities += $this
->queryLoad($ids);
}
return $entities;
}