blob: a2c4a2c7676ef5cfbe67477a9459ff7523e7de5c (
plain)
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
45
46
47
48
49
50
|
<?php
namespace Kanboard\Core\Queue;
use Kanboard\Core\Base;
use Kanboard\Job\BaseJob;
use SimpleQueue\Job;
/**
* Class JobHandler
*
* @package Kanboard\Core\Queue
* @author Frederic Guillot
*/
class JobHandler extends Base
{
/**
* Serialize a job
*
* @access public
* @param BaseJob $job
* @return Job
*/
public function serializeJob(BaseJob $job)
{
return new Job(array(
'class' => get_class($job),
'params' => $job->getJobParams(),
));
}
/**
* Execute a job
*
* @access public
* @param Job $job
*/
public function executeJob(Job $job)
{
$payload = $job->getBody();
$className = $payload['class'];
if (DEBUG) {
$this->logger->debug(__METHOD__.' Received job => '.$className);
}
$worker = new $className($this->container);
call_user_func_array(array($worker, 'execute'), $payload['params']);
}
}
|