mirror of
https://github.com/idanoo/php-resque
synced 2025-07-01 13:42:22 +00:00
Change job classes to be instantiated rather than calling methods statically. This obviously makes it easier for state information to be destroyed after a job runs. This change is NOT backwards compatible and requests job classes be rewritten. Jobs also no longer receive arguments in the perform/setUp/tearDown methods but instead are passed as a $args variable to the instantiated job
This commit is contained in:
parent
5dc24ebbe4
commit
5f64653149
5 changed files with 33 additions and 33 deletions
|
@ -129,15 +129,18 @@ class Resque_Job
|
|||
'Job class ' . $this->payload['class'] . ' does not contain a perform method.'
|
||||
);
|
||||
}
|
||||
|
||||
if(method_exists($this->payload['class'], 'setUp')) {
|
||||
call_user_func(array($this->payload['class'], 'setUp'), $this->payload['args']);
|
||||
|
||||
$instance = new $this->payload['class'];
|
||||
$isntance->args = $this->payload['args'];
|
||||
|
||||
if(method_exists($instance, 'setUp')) {
|
||||
$instance->setUp();
|
||||
}
|
||||
|
||||
call_user_func(array($this->payload['class'], 'perform'), $this->payload['args']);
|
||||
|
||||
if(method_exists($this->payload['class'], 'tearDown')) {
|
||||
call_user_func(array($this->payload['class'], 'tearDown'), $this->payload['args']);
|
||||
$instance->perform();
|
||||
|
||||
if(method_exists($instance, 'tearDown')) {
|
||||
$instance->tearDown();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue