function NodeViewController::__construct
Same name in other branches
- 9 core/modules/node/src/Controller/NodeViewController.php \Drupal\node\Controller\NodeViewController::__construct()
- 10 core/modules/node/src/Controller/NodeViewController.php \Drupal\node\Controller\NodeViewController::__construct()
- 11.x core/modules/node/src/Controller/NodeViewController.php \Drupal\node\Controller\NodeViewController::__construct()
Creates an NodeViewController object.
Parameters
\Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager: The entity type manager.
\Drupal\Core\Render\RendererInterface $renderer: The renderer service.
\Drupal\Core\Session\AccountInterface $current_user: The current user. For backwards compatibility this is optional, however this will be removed before Drupal 9.0.0.
\Drupal\Core\Entity\EntityRepositoryInterface $entity_repository: The entity repository.
Overrides EntityViewController::__construct
File
-
core/
modules/ node/ src/ Controller/ NodeViewController.php, line 45
Class
- NodeViewController
- Defines a controller to render a single node.
Namespace
Drupal\node\ControllerCode
public function __construct(EntityTypeManagerInterface $entity_type_manager, RendererInterface $renderer, AccountInterface $current_user = NULL, EntityRepositoryInterface $entity_repository = NULL) {
parent::__construct($entity_type_manager, $renderer);
$this->currentUser = $current_user ?: \Drupal::currentUser();
if (!$entity_repository) {
@trigger_error('The entity.repository service must be passed to NodeViewController::__construct(), it is required before Drupal 9.0.0. See https://www.drupal.org/node/2549139.', E_USER_DEPRECATED);
$entity_repository = \Drupal::service('entity.repository');
}
$this->entityRepository = $entity_repository;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.