public function WebformSubmissionSubmittedToLabel::render in Webform Views Integration 8.5
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/ WebformSubmissionSubmittedToLabel.php, line 91
Class
- WebformSubmissionSubmittedToLabel
- Display entity label which a webform submission was submitted to.
Namespace
Drupal\webform_views\Plugin\views\fieldCode
public function render(ResultRow $values) {
$build = [];
$source_entity = $this
->getSourceEntity($values);
if (!$source_entity) {
return $build;
}
$source_entity = $this
->getEntityTranslation($source_entity, $values);
if (isset($source_entity)) {
$access = $source_entity
->access('view', NULL, TRUE);
$build['#access'] = $access;
if ($access
->isAllowed()) {
if ($this->options['link']) {
$build['entity_label'] = $source_entity
->toLink()
->toRenderable();
}
else {
$build['entity_label'] = [
'#plain_text' => $source_entity
->label(),
];
}
$cache = CacheableMetadata::createFromObject($source_entity);
$cache
->applyTo($build);
}
}
return $build;
}