diff -u b/core/modules/book/src/Plugin/Block/BookNavigationBlock.php b/core/modules/book/src/Plugin/Block/BookNavigationBlock.php --- b/core/modules/book/src/Plugin/Block/BookNavigationBlock.php +++ b/core/modules/book/src/Plugin/Block/BookNavigationBlock.php @@ -13,7 +13,7 @@ use Drupal\Core\Plugin\ContainerFactoryPluginInterface; use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\HttpFoundation\RequestStack; -use Drupal\node\Entity\Node; +use Drupal\Core\Entity\EntityStorageInterface; /** * Provides a 'Book navigation' block. @@ -41,6 +41,13 @@ protected $bookManager; /** + * The node storage. + * + * @var \Drupal\Core\Entity\EntityStorageInterface + */ + protected $nodeStorage; + + /** * Constructs a new BookNavigationBlock instance. * * @param array $configuration @@ -53,12 +60,15 @@ * The request stack object. * @param \Drupal\book\BookManagerInterface $book_manager * The book manager. + * @param \Drupal\Core\Entity\EntityStorageInterface $node_storage + * The node storage. */ - public function __construct(array $configuration, $plugin_id, $plugin_definition, RequestStack $request_stack, BookManagerInterface $book_manager) { + public function __construct(array $configuration, $plugin_id, $plugin_definition, RequestStack $request_stack, BookManagerInterface $book_manager, EntityStorageInterface $node_storage) { parent::__construct($configuration, $plugin_id, $plugin_definition); $this->requestStack = $request_stack; $this->bookManager = $book_manager; + $this->nodeStorage = $node_storage; } /** @@ -70,7 +80,8 @@ $plugin_id, $plugin_definition, $container->get('request_stack'), - $container->get('book.manager') + $container->get('book.manager'), + $container->get('entity.manager')->getStorage('node') ); } @@ -133,7 +144,7 @@ // is no reason to run an additional menu tree query for each book. $book['in_active_trail'] = FALSE; // Check whether user can access the book link. - $book_node = Node::load($book['nid']); + $book_node = $this->nodeStorage->load($book['nid']); $book['access'] = $book_node->access('view'); $pseudo_tree[0]['link'] = $book; $book_menus[$book_id] = $this->bookManager->bookTreeOutput($pseudo_tree); diff -u b/core/modules/comment/src/Controller/CommentController.php b/core/modules/comment/src/Controller/CommentController.php --- b/core/modules/comment/src/Controller/CommentController.php +++ b/core/modules/comment/src/Controller/CommentController.php @@ -19,7 +19,7 @@ use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException; use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; use Symfony\Component\HttpKernel\HttpKernelInterface; -use Drupal\node\Entity\Node; +use Drupal\Core\Entity\EntityStorageInterface; /** * Controller for the comment entity. @@ -43,16 +43,26 @@ protected $commentManager; /** + * The node storage. + * + * @var \Drupal\Core\Entity\EntityStorageInterface + */ + protected $nodeStorage; + + /** * Constructs a CommentController object. * * @param \Symfony\Component\HttpKernel\HttpKernelInterface $http_kernel * HTTP kernel to handle requests. * @param \Drupal\comment\CommentManagerInterface $comment_manager * The comment manager service. + * @param \Drupal\Core\Entity\EntityStorageInterface $node_storage + * The node storage. */ - public function __construct(HttpKernelInterface $http_kernel, CommentManagerInterface $comment_manager) { + public function __construct(HttpKernelInterface $http_kernel, CommentManagerInterface $comment_manager, EntityStorageInterface $node_storage) { $this->httpKernel = $http_kernel; $this->commentManager = $comment_manager; + $this->nodeStorage = $node_storage; } /** @@ -61,7 +71,8 @@ public static function create(ContainerInterface $container) { return new static( $container->get('http_kernel'), - $container->get('comment.manager') + $container->get('comment.manager'), + $container->get('entity.manager')->getStorage('node') ); } @@ -286,7 +297,7 @@ $links = array(); foreach ($nids as $nid) { - $node = Node::load($nid); + $node = $this->nodeStorage->load($nid); $new = $this->commentManager->getCountNewComments($node); $page_number = $this->entityManager()->getStorage('comment') ->getNewCommentPageNumber($node->{$field_name}->comment_count, $new, $node);