From 53647fe2d254f13443e41a10f9826b051518a0b0 Mon Sep 17 00:00:00 2001 From: Oreolek Date: Wed, 29 Jan 2014 20:06:13 +0700 Subject: [PATCH] Minion integration --- .gitmodules | 3 +++ application/bootstrap.php | 1 + index.php | 26 ++++++++++++++++++-------- minion | 4 ++++ modules/minion | 1 + 5 files changed, 27 insertions(+), 8 deletions(-) create mode 100755 minion create mode 160000 modules/minion diff --git a/.gitmodules b/.gitmodules index 8b62fba..f0f7296 100644 --- a/.gitmodules +++ b/.gitmodules @@ -22,3 +22,6 @@ [submodule "modules/email"] path = modules/email url = git@github.com:shadowhand/email.git +[submodule "modules/minion"] + path = modules/minion + url = git@github.com:kohana/minion.git diff --git a/application/bootstrap.php b/application/bootstrap.php index ddd90d8..1de4a0e 100644 --- a/application/bootstrap.php +++ b/application/bootstrap.php @@ -113,6 +113,7 @@ Kohana::modules(array( 'debug-toolbar' => MODPATH.'debug-toolbar', // Debug toolbar 'kostache' => MODPATH.'kostache', // Logic-less Mustache views 'email' => MODPATH.'email', // Electronic mail class + 'minion' => MODPATH.'minion', // CLI framework )); /** diff --git a/index.php b/index.php index 815453d..cf9ee40 100644 --- a/index.php +++ b/index.php @@ -102,11 +102,21 @@ if ( ! defined('KOHANA_START_MEMORY')) // Bootstrap the application require APPPATH.'bootstrap'.EXT; -/** - * Execute the main request. A source of the URI can be passed, eg: $_SERVER['PATH_INFO']. - * If no source is specified, the URI will be automatically detected. - */ -echo Request::factory() - ->execute() - ->send_headers() - ->body(); +if (PHP_SAPI == 'cli') // Try and load minion +{ + class_exists('Minion_Task') OR die('Please enable the Minion module for CLI support.'); + set_exception_handler(array('Minion_Exception', 'handler')); + + Minion_Task::factory(Minion_CLI::options())->execute(); +} +else +{ + /** + * Execute the main request. A source of the URI can be passed, eg: $_SERVER['PATH_INFO']. + * If no source is specified, the URI will be automatically detected. + */ + echo Request::factory(TRUE, array(), FALSE) + ->execute() + ->send_headers(TRUE) + ->body(); +} diff --git a/minion b/minion new file mode 100755 index 0000000..8bf88b0 --- /dev/null +++ b/minion @@ -0,0 +1,4 @@ +#!/usr/bin/env php +