diff --git a/.gitignore b/.gitignore index 3f25141..f171a7f 100644 --- a/.gitignore +++ b/.gitignore @@ -2,4 +2,6 @@ /composer.phar /node_modules/ /build/ -/.idea/ \ No newline at end of file +/.idea/ +src/tmp/* +!src/tmp/empty \ No newline at end of file diff --git a/config/bootstrap_config.php b/config/bootstrap_config.php deleted file mode 100644 index 94ab521..0000000 --- a/config/bootstrap_config.php +++ /dev/null @@ -1,37 +0,0 @@ - - * @copyright Copyright 2012, Ber Clausen - * @link http://cakeresque.kamisama.me - * @package CakeResque - * @subpackage CakeResque.Config - * @since 3.4.0 - * @license MIT License (http://www.opensource.org/licenses/mit-license.php) - */ - -/** - * Bootstrap configuration file. - * - * It is intended to ease bootstrapping CakeResque with a custom configuration. - * - * CakePlugin::load('CakeResque', array('bootstrap' => ['bootstrap_config', '../../../Config/cakeresque', 'bootstrap'])); - * - * Where '../../../Config/cakeresque' indicates the path to the App's custom configuration file: - * - * // APP/Config/cakeresque.php - * Configure::write('CakeResque.Redis.host', 'my_hostname'); - * - * @see CakeResque::init(), CakeResque::loadConfig(). - */ -Configure::load('CakeResque.config'); diff --git a/src/CakeResqueBootstrap.php b/src/CakeResqueBootstrap.php index 6d98897..c618bf3 100644 --- a/src/CakeResqueBootstrap.php +++ b/src/CakeResqueBootstrap.php @@ -18,10 +18,30 @@ * @since 0.5 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ +include getenv('APP') . '../config/bootstrap.php'; use Cake\Console\ShellDispatcher; -use Cake\Console\Shell; -use CakeResque\Resque_Job_Creator; -define('APP', getenv('APP')); +class Resque_Job_Creator +{ -new ShellDispatcher($argv); + /** + * Create and return a job instance + * + * @param string $className className of the job to instanciate + * @param array $args Array of method name and arguments used to build the job + * @return object $args a job instance + * @throws Resque_Exception when the class is not found, or does not follow the job file convention + */ + public static function createJob($className, $args) + { + if (!class_exists('Cake\Console\ShellDispatcher')) { + throw new Resque_Exception('Resque_Job_Creator could not find Cake\Console\ShellDispatcher.'); + } + + array_unshift($args, 'void', $className); + $args[] = '-q'; + + return [new Cake\Console\ShellDispatcher($args),'dispatch']; + + } +} \ No newline at end of file diff --git a/src/Resque_Job_Creator.php b/src/Resque_Job_Creator.php deleted file mode 100644 index f4affca..0000000 --- a/src/Resque_Job_Creator.php +++ /dev/null @@ -1,71 +0,0 @@ -addSubcommand('load', [ 'help' => __d('cake_resque', 'Load a set of predefined workers.'), + ]) + ->addSubcommand('enqueue', [ + 'help' => __d('cake_resque', 'Enqueue a job.'), ]); } @@ -1270,7 +1273,7 @@ public function stats() $this->out("\t - " . __d('cake_resque', 'Delayed Jobs') . " : " . $delayedJobCount); if ($delayedJobCount > 0) { - $this->out("\t - " . __d('cake_resque', 'Next Job on') . " : " . strftime('%a %b %d %H:%M:%S %Z %Y', $schedulerWorker->nextDelayedTimestamp())); + $this->out("\t - " . __d('cake_resque', 'Next Job on') . " : " . strftime('%a %b %d %H:%M:%S %Z %Y', $schedulerWorker->nextDelayedTimestamp(null,true))); } } $this->out("\n");