You are here

protected function ShareMessageTestBase::setEntityRawContent in Share Message 8

Prepares the renderer array for a specific context, sets its raw content.

Parameters

string $entity_type: The entity type for this view builder.

\Drupal\Core\Entity\EntityInterface $entity: The entity to render.

string $view_mode: (optional) The view mode that should be used to render the entity. Defaults to 'teaser'.

1 call to ShareMessageTestBase::setEntityRawContent()
ShareMessageExtraFieldTest::testShareMessageExtraFieldToken in tests/src/Functional/ShareMessageExtraFieldTest.php
Tests the Share Message extra field functionality with tokens.

File

tests/src/Functional/ShareMessageTestBase.php, line 74

Class

ShareMessageTestBase

Namespace

Drupal\Tests\sharemessage\Functional

Code

protected function setEntityRawContent($entity_type, $entity, $view_mode = 'teaser') {

  // The structured array describing the data to be rendered.
  $elements = \Drupal::entityTypeManager()
    ->getViewBuilder($entity_type)
    ->view($entity, $view_mode);
  $content = \Drupal::service('renderer')
    ->renderRoot($elements);
  $this->renderedEntity = (string) $content;
}