PluginProbe ʕ •ᴥ•ʔ
WP STAGING – WordPress Backups, Restore, Migration & Clone / trunk
WP STAGING – WordPress Backups, Restore, Migration & Clone vtrunk
4.11.0 4.10.0 4.9.5 4.9.4 4.9.3 4.9.2 4.9.1 4.9.0 4.8.1 trunk 3.0.0 3.0.1 3.0.2 3.0.3 3.0.4 3.0.5 3.0.6 3.1.0 3.1.1 3.1.2 3.1.3 3.1.4 3.10.0 3.2.0 3.3.1 3.3.2 3.3.3 3.4.1 3.4.3 3.5.0 3.6.0 3.7.1 3.8.0 3.8.1 3.8.2 3.8.3 3.8.4 3.8.5 3.8.6 3.8.7 3.9.0 3.9.1 3.9.2 3.9.3 3.9.4 4.0.0 4.1.0 4.1.1 4.1.2 4.1.3 4.1.4 4.2.0 4.2.1 4.3.0 4.3.1 4.3.2 4.4.0 4.5.0 4.6.0 4.7.0 4.7.1 4.7.2 4.7.3 4.8.0
wp-staging / Framework / Queue / Queue.php
wp-staging / Framework / Queue Last commit date
Storage 3 days ago FileSeekableQueue.php 3 days ago FinishedQueueException.php 5 years ago Queue.php 3 days ago QueueInterface.php 3 days ago SeekableQueueInterface.php 3 days ago
Queue.php
150 lines
1 <?php
2
3
4
5
6 namespace WPStaging\Framework\Queue;
7
8 use WPStaging\Framework\Queue\Storage\CacheStorage;
9 use WPStaging\Framework\Queue\Storage\StorageInterface;
10 use WPStaging\Framework\Job\Task\AbstractTask;
11
12
13
14
15
16 class Queue implements QueueInterface
17 {
18
19 private $name;
20
21
22 private $storage;
23
24
25
26
27 public function setName($name)
28 {
29 $this->name = $name;
30 $this->init();
31 }
32
33
34
35
36 public function getName()
37 {
38 return $this->name;
39 }
40
41
42
43
44 public function setStorage(StorageInterface $storage)
45 {
46 $this->storage = $storage;
47 $this->init();
48
49 return $this;
50 }
51
52
53
54
55 public function getStorage()
56 {
57 return $this->storage;
58 }
59
60
61
62
63 public function count()
64 {
65 return $this->storage->count();
66 }
67
68
69
70
71
72
73 public function current()
74 {
75 return $this->storage->current();
76 }
77
78
79
80
81 public function pop()
82 {
83 return $this->storage->first();
84 }
85
86 public function last()
87 {
88 return $this->storage->last();
89 }
90
91
92
93
94 public function push($value)
95 {
96 $this->storage->append($value);
97 }
98
99
100
101
102 public function pushAsArray(array $value = [])
103 {
104 foreach ($value as $item) {
105 $this->storage->append($item);
106 }
107 }
108
109
110
111
112 public function prepend($value)
113 {
114 $this->storage->prepend($value);
115 }
116
117 protected function init()
118 {
119 if (!$this->name || !$this->storage) {
120 return;
121 }
122
123 $this->storage->setKey($this->name);
124 }
125
126
127
128
129 public function reset()
130 {
131 $this->storage->reset();
132 }
133
134
135
136
137 public function reverse()
138 {
139 $this->storage->reverse();
140 }
141
142
143
144
145 public function save()
146 {
147 $this->storage->commit();
148 }
149 }
150