Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 18 additions & 5 deletions lib/Qless/Job.php
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ public function perform() {
try {
$instance = $this->getInstance();

$performMethod = $this->data['performMethod'];
$performMethod = $this->getPerformMethod();

$instance->$performMethod($this);

Expand Down Expand Up @@ -377,7 +377,7 @@ public function timeout() {

/**
* Get the instance of the class specified on this job. This instance will
* be used to call the payload['performMethod']
* be used to call the payload['performMethod'] (or "perform" if not specified)
* @return mixed
* @throws \Exception
*/
Expand All @@ -392,9 +392,11 @@ public function getInstance() {
);
}

if (!method_exists($this->klass_name, $this->data['performMethod'])) {
$performMethod = $this->getPerformMethod();

if (!method_exists($this->klass_name, $performMethod)) {
throw new \Exception(
'Job class ' . $this->klass_name . ' does not contain perform method ' . $this->data['performMethod']
'Job class ' . $this->klass_name . ' does not contain perform method ' . $performMethod
);
}

Expand All @@ -403,4 +405,15 @@ public function getInstance() {
return $this->instance;
}

}
/**
* Gets method to execute on the instance (defaults to "perform")
* @return string
*/
private function getPerformMethod() {
if (is_array($this->data) && array_key_exists('performMethod', $this->data)) {
return $this->data['performMethod'];
} else {
return 'perform';
}
}
}