You are here

protected function PrevnextService::getNodesOfType in Prevnext 2.x

Same name and namespace in other branches
  1. 8 src/PrevnextService.php \Drupal\prevnext\PrevnextService::getNodesOfType()
  2. 2.0.x src/PrevnextService.php \Drupal\prevnext\PrevnextService::getNodesOfType()

Retrieves all nodes of the same type and language of given.

Parameters

\Drupal\node\Entity\Node $node: The node entity.

Return value

array An array of nodes filtered by type, status and language.

1 call to PrevnextService::getNodesOfType()
PrevnextService::getPreviousNext in src/PrevnextService.php
Retrieves previous and next nids of a given node, if they exist.

File

src/PrevnextService.php, line 63

Class

PrevnextService
Class PrevnextService.

Namespace

Drupal\prevnext

Code

protected function getNodesOfType(Node $node) {
  $query = $this->entityTypeManager
    ->getStorage('node')
    ->getQuery();
  $bundle = $node
    ->bundle();
  $langcode = $node
    ->language()
    ->getId();
  $nodes = $query
    ->condition('status', NodeInterface::PUBLISHED)
    ->condition('type', $bundle)
    ->condition('langcode', $langcode)
    ->addMetaData('type', $bundle)
    ->addMetaData('langcode', $langcode)
    ->addTag('prev_next_nodes_type')
    ->execute();
  return array_values($nodes);
}