Console Class Reference
[Console]
Helper class for console invoking. More...
Static Public Member Functions |
|
static | init () |
Init the system to be ready for console.
|
|
static | invoke ($action) |
Run console with given action. |
|
static | is_console_request () |
Returns true, if PHP was invoked from the
command line, not by the web server. |
Detailed Description
Helper class for console invoking.
Definition at line 8 of file console.cls.php.
Member Function Documentation
static Console::init | ( | ) | [static] |
Init the system to be ready for console.
Definition at line 12 of file console.cls.php.
00012 { 00013 if (!self::is_console_request()) { 00014 throw new Exception('Initialing console, but no console invoked'); 00015 } 00016 // Build $_GET and $_POST array 00017 $argv = Arr::force($_SERVER['argv']); 00018 $action = Arr::get_item($argv, 1, ''); 00019 parse_str(Arr::get_item($argv, 2, ''), $query); 00020 $method = strtoupper(Arr::get_item($argv, 3, 'GET')); 00021 00022 if (empty($action)) { 00023 $cmd = Arr::get_item($argv, 0, 'no command set'); 00024 throw new Exception("Usage: $cmd route [arguments] [get|post]"); 00025 } 00026 00027 // Fake Post and Get array 00028 if ($method == 'POST') { 00029 $_POST = $query; 00030 $_GET = array(); 00031 } 00032 else { 00033 $_POST = array(); 00034 $_GET = $query; 00035 } 00036 $_GET[Config::get_value(Config::QUERY_PARAM_PATH_INVOKED)] = $action; 00037 00038 // Disable HTTPS 00039 Config::set_feature(Config::ENABLE_HTTPS, false); 00040 00041 return $action; 00042 }
static Console::invoke | ( | $ | action | ) | [static] |
Run console with given action.
- Parameters:
-
string $action
- Returns:
- Status
Definition at line 59 of file console.cls.php.
00059 { 00060 $call = CONSOLE_PHP_INVOCATION . ' ' . APP_INCLUDE_ABSPATH . 'run_console.php ' . $action; 00061 Load::commands('generics/execute.shell'); 00062 $cmd = new ExecuteShellCommand($call); 00063 return $cmd->execute(); 00064 }
static Console::is_console_request | ( | ) | [static] |
Returns true, if PHP was invoked from the command line, not by the web server.
- Returns:
- bool
Definition at line 49 of file console.cls.php.
00049 { 00050 return RequestInfo::current()->is_console(); 00051 }
The documentation for this class was generated from the following file:
- gyro/modules/console/lib/components/console.cls.php