protected function PrevnextService::getNodesOfType in Prevnext 8
Same name and namespace in other branches
- 2.x src/PrevnextService.php \Drupal\prevnext\PrevnextService::getNodesOfType()
- 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 $nodes 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 62
Class
- PrevnextService
- Class PrevnextService.
Namespace
Drupal\prevnextCode
protected function getNodesOfType(Node $node) {
$query = $this->queryFactory
->get('node');
$bundle = $node
->bundle();
$langcode = $node
->language()
->getId();
$nodes = $query
->condition('status', NODE_PUBLISHED)
->condition('type', $bundle)
->condition('langcode', $langcode)
->addMetaData('type', $bundle)
->addMetaData('langcode', $langcode)
->addTag('prev_next_nodes_type')
->execute();
return array_values($nodes);
}