-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathQueue.php
More file actions
44 lines (36 loc) · 945 Bytes
/
Queue.php
File metadata and controls
44 lines (36 loc) · 945 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
<?php
namespace Xaav\QueueBundle\Queue;
use Xaav\QueueBundle\Queue\Job\JobInterface;
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Xaav\QueueBundle\Queue\Adapter\QueueAdapterInterface;
class Queue implements QueueInterface
{
/**
* @var QueueAdapterInterface
*/
protected $adapter;
/**
* @var ContainerInterface
*/
protected $container;
protected $name;
public function __construct(QueueAdapterInterface $adapter, ContainerInterface $container, $name)
{
$this->adapter = $adapter;
$this->container = $container;
$this->name = $name;
}
public function get()
{
$job = unserialize($this->adapter->get($this->name));
if ($job instanceof ContainerAwareInterface) {
$job->setContainer($this->container);
}
return $job;
}
public function add(JobInterface $job)
{
$this->adapter->add($this->name, serialize($job));
}
}