d3001a45c77bc0dd2aa2ca7206e2101104f1ac72
[yaffs-website] / vendor / drush / drush / lib / Drush / Queue / QueueBase.php
1 <?php
2
3 namespace Drush\Queue;
4
5 abstract class QueueBase implements QueueInterface {
6
7   /**
8    * Keep track of queue definitions.
9    *
10    * @var array
11    */
12   protected static $queues;
13
14   /**
15    * Lists all available queues.
16    */
17   public function listQueues() {
18     $result = array();
19     foreach (array_keys($this->getQueues()) as $name) {
20       $q = $this->getQueue($name);
21       $result[$name] = array(
22         'queue' => $name,
23         'items' => $q->numberOfItems(),
24         'class' => get_class($q),
25       );
26     }
27     return $result;
28   }
29
30   /**
31    * {@inheritdoc}
32    */
33   public function getInfo($name) {
34     $queues = $this->getQueues();
35     if (!isset($queues[$name])) {
36       throw new QueueException(dt('Could not find the !name queue.', array('!name' => $name)));
37     }
38     return $queues[$name];
39   }
40
41 }