Last active
February 2, 2017 15:40
-
-
Save hmic/ac210aa7b73511e21977abfcbd6616c7 to your computer and use it in GitHub Desktop.
Wrapper class to allow arbitrary number of arguments to jobs with queuesadilla
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace App\Lib; | |
class QueueWrapper | |
{ | |
static function extract($job) | |
{ | |
$callable = $job->data('callable'); | |
if(is_array($callable) && count($callable) == 2) { | |
$instance = new $callable[0]; | |
return call_user_func_array([$instance, $callable[1]], $job->data('args')); | |
} | |
return call_user_func_array($callable, $job->data('args')); | |
} | |
} | |
// call with: Queue::push(['App\Lib\QueueWrapper::extract'], ['callable '=> [__CLASS__, 'some_job'], 'args' => [1, 'me']]); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment