Commit 90c2ae96 authored by Lenovo's avatar Lenovo
Browse files

Check node is node entity

parent 47752248
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -11,6 +11,7 @@ use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\HttpFoundation\RequestStack;
use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drupal\node\NodeInterface;

/**
 * Provides a 'Next Previous' block.
@@ -125,7 +126,7 @@ class NextPreviousBlock extends BlockBase implements BlockPluginInterface, Conta
    // Get the created time of the current node.
    $node = $this->request->attributes->get('node');

    if ($node && $node->bundle() == $this->configuration['content_type']) {
    if ($node instanceof NodeInterface && $node->bundle() == $this->configuration['content_type']) {
      $current_nid = $node->get('nid')->getValue()[0]['value'];
      $link['prev'] = $this->generatePrevious($current_nid);
      $link['next'] = $this->generateNext($current_nid);