You are here

public function LayoutParagraphsFormatter::buildEntityView in Layout Paragraphs 1.0.x

Renders a paragraph entity.

Parameters

\Drupal\paragraphs\ParagraphInterface $entity: The paragraph entity to render.

Return value

array Returns a render array.

2 calls to LayoutParagraphsFormatter::buildEntityView()
LayoutParagraphsFormatter::buildLayoutContainer in src/Plugin/Field/FieldFormatter/LayoutParagraphsFormatter.php
Builds the structure for a single layout paragraph item.
LayoutParagraphsFormatter::buildLayoutTree in src/Plugin/Field/FieldFormatter/LayoutParagraphsFormatter.php
Builds the structure for the entire layout.

File

src/Plugin/Field/FieldFormatter/LayoutParagraphsFormatter.php, line 143

Class

LayoutParagraphsFormatter
Layout Paragraphs field formatter.

Namespace

Drupal\layout_paragraphs\Plugin\Field\FieldFormatter

Code

public function buildEntityView(ParagraphInterface $entity) {
  $view_mode = $this
    ->getSetting('view_mode');
  $view_builder = \Drupal::entityTypeManager()
    ->getViewBuilder($entity
    ->getEntityTypeId());
  $render_array = $view_builder
    ->view($entity, $view_mode, $entity
    ->language()
    ->getId());
  $render_array['#access'] = $this
    ->checkAccess($entity);
  return $render_array;
}