public function EntityQueueInQueue::query in Entityqueue 8
Same name in this branch
- 8 src/Plugin/views/filter/EntityQueueInQueue.php \Drupal\entityqueue\Plugin\views\filter\EntityQueueInQueue::query()
- 8 src/Plugin/views/sort/EntityQueueInQueue.php \Drupal\entityqueue\Plugin\views\sort\EntityQueueInQueue::query()
.
Overrides SortPluginBase::query
File
- src/
Plugin/ views/ sort/ EntityQueueInQueue.php, line 71
Class
- EntityQueueInQueue
- Sort handler for ordering the results based on their queue position.
Namespace
Drupal\entityqueue\Plugin\views\sortCode
public function query() {
$this
->ensureMyTable();
// Try to find an entity queue relationship in this view, and pick the first
// one available.
$entity_queue_relationship = NULL;
foreach ($this->view->relationship as $id => $relationship) {
if ($relationship instanceof EntityQueueRelationship) {
$entity_queue_relationship = $relationship;
$this->options['relationship'] = $id;
$this
->setRelationship();
break;
}
}
if ($entity_queue_relationship) {
// Add the field.
$subqueue_items_table_alias = $entity_queue_relationship->first_alias;
$this->query
->addOrderBy($subqueue_items_table_alias, 'bundle', $this->options['order']);
}
else {
if ($this->currentUser
->hasPermission('administer views')) {
$this->messenger
->addMessage($this
->t('In order to sort by whether an item is in a queue or not, you need to add an <em>Entityqueue</em> relationship on the %display display of the %view view.', [
'%view' => $this->view->storage
->label(),
'%display' => $this->view->current_display,
]), MessengerInterface::TYPE_ERROR);
}
}
}