Skip to content

Instantly share code, notes, and snippets.

@hmic
Last active February 2, 2017 15:40
Show Gist options
  • Save hmic/ac210aa7b73511e21977abfcbd6616c7 to your computer and use it in GitHub Desktop.
Save hmic/ac210aa7b73511e21977abfcbd6616c7 to your computer and use it in GitHub Desktop.
Wrapper class to allow arbitrary number of arguments to jobs with queuesadilla
<?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