You are here

class EntityQueueRepository in Entityqueue 8

Class EntityQueueRepository.

Hierarchy

Expanded class hierarchy of EntityQueueRepository

1 string reference to 'EntityQueueRepository'
entityqueue.services.yml in ./entityqueue.services.yml
entityqueue.services.yml
1 service uses EntityQueueRepository
entityqueue.repository in ./entityqueue.services.yml
Drupal\entityqueue\EntityQueueRepository

File

src/EntityQueueRepository.php, line 11

Namespace

Drupal\entityqueue
View source
class EntityQueueRepository implements EntityQueueRepositoryInterface {

  /**
   * Drupal\Core\Entity\EntityTypeManagerInterface definition.
   *
   * @var \Drupal\Core\Entity\EntityTypeManagerInterface
   */
  protected $entityTypeManager;

  /**
   * Constructs a new EntityQueueRepository object.
   */
  public function __construct(EntityTypeManagerInterface $entity_type_manager) {
    $this->entityTypeManager = $entity_type_manager;
  }

  /**
   * {@inheritdoc}
   */
  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;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
EntityQueueRepository::$entityTypeManager protected property Drupal\Core\Entity\EntityTypeManagerInterface definition.
EntityQueueRepository::getAvailableQueuesForEntity public function Gets a list of queues which can hold this entity. Overrides EntityQueueRepositoryInterface::getAvailableQueuesForEntity
EntityQueueRepository::__construct public function Constructs a new EntityQueueRepository object.