Unverified Commit 177e4f8a authored by Alex Pott's avatar Alex Pott
Browse files

task: #3589630 Deprecate NodeViewController

By: acbramley
By: larowlan
By: alexpott
parent f56d20ef
Loading
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -6,6 +6,7 @@
use Drupal\Core\Controller\ControllerBase;
use Drupal\Core\Datetime\DateFormatterInterface;
use Drupal\Core\DependencyInjection\ContainerInjectionInterface;
use Drupal\Core\Entity\Controller\EntityViewController;
use Drupal\Core\Entity\EntityRepositoryInterface;
use Drupal\Core\Link;
use Drupal\Core\Render\RendererInterface;
@@ -110,7 +111,7 @@ public function addPage() {
   *   An array suitable for \Drupal\Core\Render\RendererInterface::render().
   */
  public function revisionShow(NodeInterface $node_revision) {
    $node_view_controller = new NodeViewController($this->entityTypeManager(), $this->renderer, $this->currentUser(), $this->entityRepository);
    $node_view_controller = new EntityViewController($this->entityTypeManager(), $this->renderer);
    $page = $node_view_controller->view($node_revision);
    unset($page['nodes'][$node_revision->id()]['#cache']);
    return $page;
+6 −0
Original line number Diff line number Diff line
@@ -12,6 +12,11 @@

/**
 * Defines a controller to render a single node.
 *
 * @deprecated in drupal:11.4.0 and is removed from drupal:13.0.0. Use
 *   \Drupal\Core\Entity\Controller\EntityViewController instead.
 *
 * @see https://www.drupal.org/node/3589636
 */
class NodeViewController extends EntityViewController {

@@ -42,6 +47,7 @@ class NodeViewController extends EntityViewController {
   *   The entity repository.
   */
  public function __construct(EntityTypeManagerInterface $entity_type_manager, RendererInterface $renderer, AccountInterface $current_user, EntityRepositoryInterface $entity_repository) {
    @trigger_error(__CLASS__ . ' is deprecated in drupal:11.4.0 and is removed from drupal:13.0.0. Use \Drupal\Core\Entity\Controller\EntityViewController instead. See https://www.drupal.org/node/3589636', E_USER_DEPRECATED);
    parent::__construct($entity_type_manager, $renderer);
    $this->currentUser = $current_user;
    $this->entityRepository = $entity_repository;
+0 −10
Original line number Diff line number Diff line
@@ -5,7 +5,6 @@
use Drupal\Core\Entity\EntityTypeInterface;
use Drupal\Core\Entity\Routing\DefaultHtmlRouteProvider;
use Drupal\node\Controller\NodeController;
use Drupal\node\Controller\NodeViewController;

/**
 * Provides routes for nodes.
@@ -53,15 +52,6 @@ protected function getAddFormRoute(EntityTypeInterface $entity_type) {
    }
  }

  /**
   * {@inheritdoc}
   */
  protected function getCanonicalRoute(EntityTypeInterface $entity_type) {
    if ($route = parent::getCanonicalRoute($entity_type)) {
      return $route->setDefault('_controller', NodeViewController::class . '::view');
    }
  }

  /**
   * {@inheritdoc}
   */