public function EntityQueueRepository::getAvailableQueuesForEntity in Entityqueue 8
Gets a list of queues which can hold this entity.
Parameters
\Drupal\Core\Entity\EntityInterface $entity: An entity object.
Return value
\Drupal\entityqueue\EntityQueueInterface[] An array of entity queues which can hold this entity.
Overrides EntityQueueRepositoryInterface::getAvailableQueuesForEntity
File
- src/
EntityQueueRepository.php, line 30
Class
- EntityQueueRepository
- Class EntityQueueRepository.
Namespace
Drupal\entityqueueCode
public function getAvailableQueuesForEntity(EntityInterface $entity) {
$storage = $this->entityTypeManager
->getStorage('entity_queue');
$queue_ids = $storage
->getQuery()
->condition('entity_settings.target_type', $entity
->getEntityTypeId(), '=')
->condition('status', TRUE)
->execute();
$queues = $storage
->loadMultiple($queue_ids);
$queues = array_filter($queues, function ($queue) use ($entity) {
/** @var \Drupal\entityqueue\EntityQueueInterface $queue */
$queue_settings = $queue
->getEntitySettings();
$target_bundles =& $queue_settings['handler_settings']['target_bundles'];
return $target_bundles === NULL || in_array($entity
->bundle(), $target_bundles, TRUE);
});
return $queues;
}