public function OpignoGroupMembership::render in Opigno Learning path 8
Same name and namespace in other branches
- 3.x src/Plugin/views/field/OpignoGroupMembership.php \Drupal\opigno_learning_path\Plugin\views\field\OpignoGroupMembership::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/ OpignoGroupMembership.php, line 27
Class
- OpignoGroupMembership
- Field handler to output boolean indication of current user membership.
Namespace
Drupal\opigno_learning_path\Plugin\views\fieldCode
public function render(ResultRow $values) {
$account = \Drupal::currentUser();
$membership_service = \Drupal::service('group.membership_loader');
$membership = $membership_service
->load($values->_entity, $account);
return $membership ? (bool) $membership : $membership;
}