From 0ef98516b843e4b6f8a3b5ca2950db9189132609 Mon Sep 17 00:00:00 2001 From: m-hume Date: Thu, 16 Feb 2017 10:38:59 +0000 Subject: [PATCH] Provide method name to TaskInterface allows for the task object to take the form ``` class myTask implements TaskInterface { protected $_data; public function run($methodName='') { if(method_exists($this, $methodName)){ return call_user_func_array(array($this, $methodName), $this->_data); } return false; } public function setData(array $data) { $this->_data = $data; } protected function myMethodThatReceivesTheDataSetAsParameters($param1, $param2) { echo "$param1 \n"; echo "$param2 \n"; } } ``` --- src/Qutee/Worker.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Qutee/Worker.php b/src/Qutee/Worker.php index e4d2fe6..b49239f 100644 --- a/src/Qutee/Worker.php +++ b/src/Qutee/Worker.php @@ -213,16 +213,16 @@ protected function _runTask(Task $task) } $taskObject = new $taskClassName; - + $methodName = $task->getMethodName(); + if ($taskObject instanceof TaskInterface) { $taskObject->setData($task->getData()); - $taskObject->run(); + $taskObject->run($methodName); return $taskObject; } else { - $methodName = $task->getMethodName(); $taskObject->$methodName($task->getData()); }