/** * Returns the number of items in a subqueue or the number of subqueues. * * @param \Drupal\entityqueue\EntityQueueInterface $queue * An entity queue object. * * @return string * The number of items in a subqueue or the number of subqueues. */ protected function getQueueItemsStatus(EntityQueueInterface $queue) { $handler = $queue->getHandlerPlugin(); $items = NULL; if ($handler->supportsMultipleSubqueues()) { $subqueues_count = $this->entityManager->getStorage('entity_subqueue')->getQuery() ->condition('queue', $queue->id(), '=') ->count() ->execute(); $items = $this->t('@count subqueues', ['@count' => $subqueues_count]); } else { $subqueue = EntitySubqueue::load($queue->id()); $items = $this->t('@count items', ['@count' => count($subqueue->items)]); } return $items; }
/** * {@inheritdoc} */ public function onQueuePostDelete(EntityQueueInterface $queue, EntityStorageInterface $storage) { // Delete the subqueue when the parent queue is deleted. if ($subqueue = EntitySubqueue::load($queue->id())) { $subqueue->delete(); } }