protected function DrupalDefaultEntityController::cacheGet
7.x entity.inc | protected DrupalDefaultEntityController::cacheGet($ids, $conditions = array()) |
Gets entities from the static cache.
Parameters
$ids: If not empty, return entities that match these IDs.
$conditions: If set, return entities that match all of these conditions.
Return value
Array of entities from the entity cache.
2 calls to DrupalDefaultEntityController::cacheGet()
- DrupalDefaultEntityController::load in drupal-7.x/
includes/ entity.inc - Implements DrupalEntityControllerInterface::load().
- TaxonomyTermController::cacheGet in drupal-7.x/
modules/ taxonomy/ taxonomy.module - Gets entities from the static cache.
1 method overrides DrupalDefaultEntityController::cacheGet()
- TaxonomyTermController::cacheGet in drupal-7.x/
modules/ taxonomy/ taxonomy.module - Gets entities from the static cache.
File
- drupal-7.x/
includes/ entity.inc, line 345
Class
- DrupalDefaultEntityController
- Default implementation of DrupalEntityControllerInterface.
Code
protected function cacheGet($ids, $conditions = array()) {
$entities = array();
// Load any available entities from the internal cache.
if (!empty($this->entityCache)) {
if ($ids) {
$entities += array_intersect_key($this->entityCache, array_flip($ids));
}
// If loading entities only by conditions, fetch all available entities
// from the cache. Entities which don't match are removed later.
elseif ($conditions) {
$entities = $this->entityCache;
}
}
// Exclude any entities loaded from cache if they don't match $conditions.
// This ensures the same behavior whether loading from memory or database.
if ($conditions) {
foreach ($entities as $entity) {
$entity_values = (array) $entity;
if (array_diff_assoc($conditions, $entity_values)) {
unset($entities[$entity->{$this->idKey}]);
}
}
}
return $entities;
}