run() public static method

If $request is null, a new request object is instantiated based on the value of the 'request' key in the $_classes array.
public static run ( object $request = null, array $options = [] ) : object
$request object An instance of a request object with console request information. If `null`, an instance will be created.
$options array
return object The command action result which is an instance of `lithium\console\Response`.
Ejemplo n.º 1
0
 public function testRunWithCamelizingAction()
 {
     $result = Dispatcher::run(new Request(array('args' => array('\\lithium\\tests\\mocks\\console\\command\\MockCommandHelp', 'sample-task-with-optional-args'))));
     $this->assertTrue($result);
     $result = Dispatcher::run(new Request(array('args' => array('\\lithium\\tests\\mocks\\console\\command\\MockCommandHelp', 'sample_task_with_optional_args'))));
     $this->assertTrue($result);
 }
Ejemplo n.º 2
0
 public function testEnvironmentIsSet()
 {
     $expected = 'production';
     $response = Dispatcher::run(new Request(array('args' => array('lithium\\tests\\mocks\\console\\MockDispatcherCommand', 'testEnv', '--env=production'))));
     $result = $response->environment;
     $this->assertEqual($expected, $result);
 }
 public function testInvalidCommand()
 {
     $expected = (object) array('status' => "Command `\\this\\command\\is\\fake` not found\n");
     $result = Dispatcher::run(new Request(array('args' => array('\\this\\command\\is\\fake', 'testAction'))));
     $this->assertEqual($expected, $result);
 }
Ejemplo n.º 4
0
 * Determine if we're in an application context by moving up the directory tree looking for
 * a `config` directory with a `bootstrap.php` file in it.  If no application context is found,
 * just boot up the core framework.
 */
$library = dirname(dirname(__DIR__));
$app = null;
$working = getcwd() ?: __DIR__;
while (!$app && $working) {
    if (file_exists($working . '/config/bootstrap.php')) {
        $app = $working;
    } elseif (file_exists($working . '/app/config/bootstrap.php')) {
        $app = $working . '/app';
    } else {
        $working = ($parent = dirname($working)) != $working ? $parent : false;
    }
}
if ($app) {
    include $app . '/config/bootstrap.php';
} else {
    define('LITHIUM_LIBRARY_PATH', $library);
    define('LITHIUM_APP_PATH', dirname($library) . '/app');
    if (!(include LITHIUM_LIBRARY_PATH . '/lithium/core/Libraries.php')) {
        $message = "Lithium core could not be found.  Check the value of `LITHIUM_LIBRARY_PATH` ";
        $message .= "in `config/bootstrap.php`. It should point to the directory containing your ";
        $message .= "`/libraries` directory.";
        trigger_error($message, E_USER_ERROR);
    }
    Libraries::add('lithium');
}
exit(Dispatcher::run()->status);