protected function NodeOrderListBuilder::getEntityIds in Node Order 8
Loads entity IDs using a pager sorted by the entity id.
Return value
array An array of entity IDs.
Overrides EntityListBuilder::getEntityIds
File
- src/
NodeOrderListBuilder.php, line 118
Class
- NodeOrderListBuilder
- Defines a class to build a listing of node entities.
Namespace
Drupal\nodeorderCode
protected function getEntityIds() {
$taxonomy_indexes = $this->database
->select('taxonomy_index', 'ti');
$taxonomy_indexes
->condition('ti.tid', $this->taxonomyTerm
->id());
$count_query = clone $taxonomy_indexes;
$count_query
->addExpression('Count(ti.nid)');
/** @var \Drupal\Core\Database\Query\PagerSelectExtender $paged_query */
$paged_query = $taxonomy_indexes
->extend(PagerSelectExtender::class);
$paged_query
->limit($this->limit);
$paged_query
->setCountQuery($count_query);
$paged_query
->fields('ti', [
'nid',
'weight',
]);
$paged_query
->orderBy('ti.weight');
$this->nodesWeight = $paged_query
->execute()
->fetchAllKeyed();
$this->entitiesCount = (int) $count_query
->execute()
->fetchField();
// Method load will be triggered later, if we pass empty array as an argument,
// method will be load all entities with type node, will be passed -1 as an
// allowed ID for node to prevent loading all entities.
// Case for term without nodes.
return $this->nodesWeight ? array_keys($this->nodesWeight) : [
-1,
];
}