public function FieldCollectionViewsHandlerFieldHostEntityPath::render in Field Collection Views 6.x
Same name and namespace in other branches
- 8.5 src/Plugin/views/field/FieldCollectionViewsHandlerFieldHostEntityPath.php \Drupal\field_collection_views\Plugin\views\field\FieldCollectionViewsHandlerFieldHostEntityPath::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/ FieldCollectionViewsHandlerFieldHostEntityPath.php, line 49
Class
- FieldCollectionViewsHandlerFieldHostEntityPath
- Field handler to flag the field_collection_views_host_path.
Namespace
Drupal\field_collection_views\Plugin\views\fieldCode
public function render(ResultRow $values) {
$host_entity_path = "";
$item_id = $values->item_id;
$field_collection_item = FieldCollectionItem::load($item_id);
$host_entity_id = $field_collection_item
->getHostId();
if (!empty($host_entity_id)) {
$host_entity_type = $field_collection_item
->get('host_type')->value;
if (!empty($host_entity_type)) {
$host_entitys = \Drupal::service('entity_type.manager')
->getStorage($host_entity_type)
->load($host_entity_id);
$host_entity_path = $host_entitys
->toUrl()
->toString();
}
}
return $host_entity_path;
}