public function entity_views_handler_field_field::get_items in Entity API 7
Overridden to get the items our way.
Overrides views_handler_field_field::get_items
File
- views/
handlers/ entity_views_handler_field_field.inc, line 77 - Contains the entity_views_handler_field_field class.
Class
- entity_views_handler_field_field
- A handler to provide proper displays for Field API fields.
Code
public function get_items($values) {
$items = array();
// Set the entity type for the parent handler.
$values->_field_data[$this->field_alias]['entity_type'] = $this->entity_type;
// We need special handling for lists of entities as the base.
$entities = EntityFieldHandlerHelper::get_value($this, $values, 'entity object');
if (!is_array($entities)) {
$entities = $entities ? array(
$entities,
) : array();
}
foreach ($entities as $entity) {
// Only try to render the field if it is even present on this bundle.
// Otherwise, field_view_field() will trigger a fatal.
list(, , $bundle) = entity_extract_ids($this->entity_type, $entity);
if (field_info_instance($this->entity_type, $this->definition['field_name'], $bundle)) {
// Set the currently rendered entity.
$values->_field_data[$this->field_alias]['entity'] = $entity;
$items = array_merge($items, $this
->set_items($values, $this->view->row_index));
}
}
return $items;
}