Skip to content
Snippets Groups Projects
Commit 3d57b15e authored by Viktor Holovachek's avatar Viktor Holovachek Committed by Adriano Cori
Browse files

Issue #3398333 by AstonVictor: Replace Node with NodeInterface

3398333 - Fix Node class
parent 161d8129
No related branches found
No related tags found
No related merge requests found
...@@ -10,7 +10,7 @@ use Drupal\Core\Entity\Display\EntityViewDisplayInterface; ...@@ -10,7 +10,7 @@ use Drupal\Core\Entity\Display\EntityViewDisplayInterface;
use Drupal\Core\Entity\EntityInterface; use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Routing\RouteMatchInterface; use Drupal\Core\Routing\RouteMatchInterface;
use Drupal\Core\Url; use Drupal\Core\Url;
use Drupal\node\Entity\Node; use Drupal\node\NodeInterface;
/** /**
* Implements hook_help(). * Implements hook_help().
...@@ -79,7 +79,7 @@ function prevnext_entity_extra_field_info() { ...@@ -79,7 +79,7 @@ function prevnext_entity_extra_field_info() {
/** /**
* Implements hook_ENTITY_TYPE_view(). * Implements hook_ENTITY_TYPE_view().
*/ */
function prevnext_node_view(array &$build, Node $node, EntityViewDisplayInterface $display, $view_mode) { function prevnext_node_view(array &$build, NodeInterface $node, EntityViewDisplayInterface $display, $view_mode) {
// Checking if current node is configured for prevnext or not. // Checking if current node is configured for prevnext or not.
$config = \Drupal::config('prevnext.settings'); $config = \Drupal::config('prevnext.settings');
...@@ -137,7 +137,7 @@ function prevnext_node_view(array &$build, Node $node, EntityViewDisplayInterfac ...@@ -137,7 +137,7 @@ function prevnext_node_view(array &$build, Node $node, EntityViewDisplayInterfac
/** /**
* Implements hook_ENTITY_TYPE_presave(). * Implements hook_ENTITY_TYPE_presave().
*/ */
function prevnext_node_presave(EntityInterface $entity) { function prevnext_node_presave(NodeInterface $entity) {
$config = \Drupal::config('prevnext.settings'); $config = \Drupal::config('prevnext.settings');
$enabled_nodetypes = $config->get('prevnext_enabled_nodetypes'); $enabled_nodetypes = $config->get('prevnext_enabled_nodetypes');
if (is_array($enabled_nodetypes) && in_array($entity->bundle(), $enabled_nodetypes)) { if (is_array($enabled_nodetypes) && in_array($entity->bundle(), $enabled_nodetypes)) {
......
...@@ -3,7 +3,6 @@ ...@@ -3,7 +3,6 @@
namespace Drupal\prevnext; namespace Drupal\prevnext;
use Drupal\Core\Entity\EntityTypeManagerInterface; use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drupal\node\Entity\Node;
use Drupal\node\NodeInterface; use Drupal\node\NodeInterface;
/** /**
...@@ -40,7 +39,7 @@ class PrevNextService implements PrevNextServiceInterface { ...@@ -40,7 +39,7 @@ class PrevNextService implements PrevNextServiceInterface {
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function getPreviousNext(Node $node) { public function getPreviousNext(NodeInterface $node) {
$nodes = $this->getNodesOfType($node); $nodes = $this->getNodesOfType($node);
$current_nid = $node->id(); $current_nid = $node->id();
...@@ -54,13 +53,13 @@ class PrevNextService implements PrevNextServiceInterface { ...@@ -54,13 +53,13 @@ class PrevNextService implements PrevNextServiceInterface {
/** /**
* Retrieves all nodes of the same type and language of given. * Retrieves all nodes of the same type and language of given.
* *
* @param \Drupal\node\Entity\Node $node * @param \Drupal\node\NodeInterface $node
* The node entity. * The node entity.
* *
* @return array * @return array
* An array of nodes filtered by type, status and language. * An array of nodes filtered by type, status and language.
*/ */
protected function getNodesOfType(Node $node) { protected function getNodesOfType(NodeInterface $node) {
$query = $this->entityTypeManager->getStorage('node')->getQuery(); $query = $this->entityTypeManager->getStorage('node')->getQuery();
$bundle = $node->bundle(); $bundle = $node->bundle();
$langcode = $node->language()->getId(); $langcode = $node->language()->getId();
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
namespace Drupal\prevnext; namespace Drupal\prevnext;
use Drupal\node\Entity\Node; use Drupal\node\NodeInterface;
/** /**
* Interface for the main service file. * Interface for the main service file.
...@@ -14,12 +14,12 @@ interface PrevNextServiceInterface { ...@@ -14,12 +14,12 @@ interface PrevNextServiceInterface {
/** /**
* Retrieves previous and next nids of a given node, if they exist. * Retrieves previous and next nids of a given node, if they exist.
* *
* @param \Drupal\node\Entity\Node $node * @param \Drupal\node\NodeInterface $node
* The node entity. * The node entity.
* *
* @return array * @return array
* An array of prev/next nids of given node. * An array of prev/next nids of given node.
*/ */
public function getPreviousNext(Node $node); public function getPreviousNext(NodeInterface $node);
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment