You are here

public function EntityViewBuilder::__construct in Drupal 8

Same name and namespace in other branches
  1. 9 core/lib/Drupal/Core/Entity/EntityViewBuilder.php \Drupal\Core\Entity\EntityViewBuilder::__construct()

Constructs a new EntityViewBuilder.

Parameters

\Drupal\Core\Entity\EntityTypeInterface $entity_type: The entity type definition.

\Drupal\Core\Entity\EntityRepositoryInterface $entity_repository: The entity repository service.

\Drupal\Core\Language\LanguageManagerInterface $language_manager: The language manager.

\Drupal\Core\Theme\Registry $theme_registry: The theme registry.

\Drupal\Core\Entity\EntityDisplayRepositoryInterface $entity_display_repository: The entity display repository.

2 calls to EntityViewBuilder::__construct()
CommentViewBuilder::__construct in core/modules/comment/src/CommentViewBuilder.php
Constructs a new CommentViewBuilder.
FeedViewBuilder::__construct in core/modules/aggregator/src/FeedViewBuilder.php
Constructs a new FeedViewBuilder.
2 methods override EntityViewBuilder::__construct()
CommentViewBuilder::__construct in core/modules/comment/src/CommentViewBuilder.php
Constructs a new CommentViewBuilder.
FeedViewBuilder::__construct in core/modules/aggregator/src/FeedViewBuilder.php
Constructs a new FeedViewBuilder.

File

core/lib/Drupal/Core/Entity/EntityViewBuilder.php, line 104

Class

EntityViewBuilder
Base class for entity view builders.

Namespace

Drupal\Core\Entity

Code

public function __construct(EntityTypeInterface $entity_type, EntityRepositoryInterface $entity_repository, LanguageManagerInterface $language_manager, Registry $theme_registry = NULL, EntityDisplayRepositoryInterface $entity_display_repository = NULL) {
  $this->entityTypeId = $entity_type
    ->id();
  $this->entityType = $entity_type;
  $this->entityRepository = $entity_repository;
  $this->languageManager = $language_manager;
  $this->themeRegistry = $theme_registry ?: \Drupal::service('theme.registry');
  if (!$entity_display_repository) {
    @trigger_error('Calling EntityViewBuilder::__construct() with the $entity_display_repository argument is supported in drupal:8.7.0 and will be required before drupal:9.0.0. See https://www.drupal.org/node/2549139.', E_USER_DEPRECATED);
    $entity_display_repository = \Drupal::service('entity_display.repository');
  }
  $this->entityDisplayRepository = $entity_display_repository;
}