public function EntityListWrapper::value in Entity API 7
Returns the list as numerically indexed array.
Note that a list of entities might contain stale entity references. In that case the wrapper and the identifier of a stale reference would be still accessible, however the entity object value would be NULL. That way, there may be NULL values in lists of entity objects due to stale entity references.
Parameters
$options: An array of options. Known keys:
- identifier: If set to TRUE for a list of entities, it won't be returned as list of fully loaded entity objects, but as a list of entity ids. Note that this list may contain ids of stale entity references.
Overrides EntityMetadataWrapper::value
2 calls to EntityListWrapper::value()
- EntityListWrapper::count in includes/
entity.wrapper.inc - EntityListWrapper::offsetExists in includes/
entity.wrapper.inc
File
- includes/
entity.wrapper.inc, line 1091 - Provides wrappers allowing easy usage of the entity metadata.
Class
- EntityListWrapper
- Wraps a list of values.
Code
public function value(array $options = array()) {
// For lists of entities fetch full entity objects before returning.
// Generic entity-wrappers need to be handled separately though.
if ($this->isEntityList && empty($options['identifier']) && $this
->dataAvailable()) {
$list = parent::value();
$entities = $list ? entity_load($this
->get(0)->type, $list) : array();
// Make sure to keep the array keys as present in the list.
foreach ($list as $key => $id) {
// In case the entity cannot be loaded, we return NULL just as for empty
// properties.
$list[$key] = isset($entities[$id]) ? $entities[$id] : NULL;
}
return $list;
}
return parent::value();
}