class NodeViewController in Drupal 9
Same name and namespace in other branches
- 8 core/modules/node/src/Controller/NodeViewController.php \Drupal\node\Controller\NodeViewController
Defines a controller to render a single node.
Hierarchy
- class \Drupal\Core\Entity\Controller\EntityViewController implements ContainerInjectionInterface, TrustedCallbackInterface
- class \Drupal\node\Controller\NodeViewController
Expanded class hierarchy of NodeViewController
File
- core/
modules/ node/ src/ Controller/ NodeViewController.php, line 16
Namespace
Drupal\node\ControllerView source
class NodeViewController extends EntityViewController {
/**
* The current user.
*
* @var \Drupal\Core\Session\AccountInterface
*/
protected $currentUser;
/**
* The entity repository service.
*
* @var \Drupal\Core\Entity\EntityRepositoryInterface
*/
protected $entityRepository;
/**
* Creates a NodeViewController object.
*
* @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager
* The entity type manager.
* @param \Drupal\Core\Render\RendererInterface $renderer
* The renderer service.
* @param \Drupal\Core\Session\AccountInterface $current_user
* The current user.
* @param \Drupal\Core\Entity\EntityRepositoryInterface $entity_repository
* The entity repository.
*/
public function __construct(EntityTypeManagerInterface $entity_type_manager, RendererInterface $renderer, AccountInterface $current_user, EntityRepositoryInterface $entity_repository) {
parent::__construct($entity_type_manager, $renderer);
$this->currentUser = $current_user;
$this->entityRepository = $entity_repository;
}
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container) {
return new static($container
->get('entity_type.manager'), $container
->get('renderer'), $container
->get('current_user'), $container
->get('entity.repository'));
}
/**
* {@inheritdoc}
*/
public function view(EntityInterface $node, $view_mode = 'full', $langcode = NULL) {
return parent::view($node, $view_mode);
}
/**
* The _title_callback for the page that renders a single node.
*
* @param \Drupal\Core\Entity\EntityInterface $node
* The current node.
*
* @return string
* The page title.
*/
public function title(EntityInterface $node) {
return $this->entityRepository
->getTranslationFromContext($node)
->label();
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
EntityViewController:: |
protected | property | The entity type manager. | |
EntityViewController:: |
protected | property | The renderer service. | |
EntityViewController:: |
public | function | Pre-render callback to build the page title. | |
EntityViewController:: |
public static | function |
Lists the trusted callbacks provided by the implementing class. Overrides TrustedCallbackInterface:: |
|
EntityViewController:: |
public | function | Provides a page to render a single entity revision. | |
NodeViewController:: |
protected | property | The current user. | |
NodeViewController:: |
protected | property | The entity repository service. | |
NodeViewController:: |
public static | function |
Instantiates a new instance of this class. Overrides EntityViewController:: |
|
NodeViewController:: |
public | function | The _title_callback for the page that renders a single node. | |
NodeViewController:: |
public | function |
Provides a page to render a single entity. Overrides EntityViewController:: |
|
NodeViewController:: |
public | function |
Creates a NodeViewController object. Overrides EntityViewController:: |
|
TrustedCallbackInterface:: |
constant | Untrusted callbacks throw exceptions. | ||
TrustedCallbackInterface:: |
constant | Untrusted callbacks trigger silenced E_USER_DEPRECATION errors. | ||
TrustedCallbackInterface:: |
constant | Untrusted callbacks trigger E_USER_WARNING errors. |