public function FieldCollectionViewsHandlerFieldCollectionId::render in Field Collection Views 8.5
Same name and namespace in other branches
- 6.x src/Plugin/views/field/FieldCollectionViewsHandlerFieldCollectionId.php \Drupal\field_collection_views\Plugin\views\field\FieldCollectionViewsHandlerFieldCollectionId::render()
Renders the field.
Parameters
\Drupal\views\ResultRow $values: The values retrieved from a single row of a view's query result.
Return value
string|\Drupal\Component\Render\MarkupInterface The rendered output. If the output is safe it will be wrapped in an object that implements MarkupInterface. If it is empty or unsafe it will be a string.
Overrides FieldPluginBase::render
File
- src/
Plugin/ views/ field/ FieldCollectionViewsHandlerFieldCollectionId.php, line 47
Class
- FieldCollectionViewsHandlerFieldCollectionId
- Field handler to flag the field_collection_views_item_id.
Namespace
Drupal\field_collection_views\Plugin\views\fieldCode
public function render(ResultRow $values) {
$field_collection_id = '';
$item_id = $values->item_id;
$field_collection_item = FieldCollectionItem::load($item_id);
$host_entity_id = $field_collection_item
->getHostId();
if (!empty($host_entity_id)) {
$field_collection_id = $item_id;
}
return $field_collection_id;
}