public function FlagViewsLinkField::render in Flag 8.4
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/ FlagViewsLinkField.php, line 119
Class
- FlagViewsLinkField
- Provides a views field to flag or unflag the selected content.
Namespace
Drupal\flag\Plugin\views\fieldCode
public function render(ResultRow $values) {
// If the flagging is the base for the view, there wouldn't be a
// relationship involved.
if ($values->_entity instanceof FlaggingInterface) {
$entity_type = $values->_entity
->getFlaggableType();
$entity_id = $values->_entity
->getFlaggableId();
$entity = $this
->getEntityTypeManager()
->getStorage($entity_type)
->load($entity_id);
$this->flag = $values->_entity
->getFlag();
}
else {
$entity = $this
->getParentRelationshipEntity($values);
}
return $this
->renderLink($entity, $values);
}