You are here

public function WebformSubmissionSubmittedToRenderedEntity::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/WebformSubmissionSubmittedToRenderedEntity.php, line 79

Class

WebformSubmissionSubmittedToRenderedEntity
Display rendered entity which a webform submission was submitted to.

Namespace

Drupal\webform_views\Plugin\views\field

Code

public function render(ResultRow $values) {
  $build = [];
  $source_entity = $this
    ->getSourceEntity($values);
  if (!$source_entity) {
    return $build;
  }
  $source_entity = $this
    ->getEntityTranslation($source_entity, $values);
  $access = $source_entity
    ->access('view', NULL, TRUE);
  $build['#access'] = $access;
  if ($access
    ->isAllowed()) {
    $view_builder = $this->entityManager
      ->getViewBuilder($this
      ->getEntityTypeId());
    $build += $view_builder
      ->view($source_entity, $this->options['view_mode']);
    $cache = CacheableMetadata::createFromObject($source_entity);
    $cache
      ->applyTo($build);
  }
  return $build;
}