public function EntityListWrapper::get in Entity API 7
Get the wrapper for a single item.
Return value
EntityMetadataWrapper An instance of EntityMetadataWrapper.
1 call to EntityListWrapper::get()
- EntityListWrapper::offsetGet in includes/
entity.wrapper.inc - Implements the ArrayAccess interface.
File
- includes/
entity.wrapper.inc, line 1033 - Provides wrappers allowing easy usage of the entity metadata.
Class
- EntityListWrapper
- Wraps a list of values.
Code
public function get($delta) {
// Look it up in the cache if possible.
if (!array_key_exists($delta, $this->cache)) {
if (!isset($delta)) {
// The [] operator has been used so point at a new entry.
$values = parent::value();
$delta = $values ? max(array_keys($values)) + 1 : 0;
}
if (is_numeric($delta)) {
$info = array(
'parent' => $this,
'name' => $delta,
) + $this->info;
$this->cache[$delta] = entity_metadata_wrapper($this->itemType, NULL, $info);
}
else {
throw new EntityMetadataWrapperException('There can be only numerical keyed items in a list.');
}
}
return $this->cache[$delta];
}