public function LikeAndDislike::render in Like & Dislike 8
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/ LikeAndDislike.php, line 71
Class
- LikeAndDislike
- Like and Dislike field handler.
Namespace
Drupal\like_and_dislike\Plugin\views\fieldCode
public function render(ResultRow $values) {
if ($entity = $values->_entity) {
if (like_and_dislike_is_enabled($entity)) {
$entity_type = $entity
->getEntityTypeId();
$entity_id = $entity
->id();
return $this->likeDislikeBuilder
->build($entity_type, $entity_id);
}
else {
return $this
->t('Enable the current entity/bundle in the Like & Dislike settings page.');
}
}
return NULL;
}