Consult /bin/cake.php for how this class is used in practice.
Exemplo n.º 1
0
 /**
  * Create the given shell name, and set the plugin property.
  *
  * @param string $className The class name to instantiate
  * @param string $shortName The plugin-prefixed shell name
  * @return \Cake\Console\Shell A shell instance.
  */
 protected function _createShell($className, $shortName)
 {
     $instance = parent::_createShell($className, $shortName);
     $webIo = new ConsoleIo(new WebConsoleOutput(), new WebConsoleOutput(), new WebConsoleInput());
     $instance->io($webIo);
     return $instance;
 }
Exemplo n.º 2
0
 /**
  * Dispatch a command to another Shell. Similar to Object::requestAction()
  * but intended for running shells from other shells.
  *
  * ### Usage:
  *
  * With a string command:
  *
  * ```
  * return $this->dispatchShell('schema create DbAcl');
  * ```
  *
  * Avoid using this form if you have string arguments, with spaces in them.
  * The dispatched will be invoked incorrectly. Only use this form for simple
  * command dispatching.
  *
  * With an array command:
  *
  * ```
  * return $this->dispatchShell('schema', 'create', 'i18n', '--dry');
  * ```
  *
  * With an array having two key / value pairs:
  *  - `command` can accept either a string or an array. Represents the command to dispatch
  *  - `extra` can accept an array of extra parameters to pass on to the dispatcher. This
  *  parameters will be available in the `param` property of the called `Shell`
  *
  * `return $this->dispatchShell([
  *      'command' => 'schema create DbAcl',
  *      'extra' => ['param' => 'value']
  * ]);`
  *
  * or
  *
  * `return $this->dispatchShell([
  *      'command' => ['schema', 'create', 'DbAcl'],
  *      'extra' => ['param' => 'value']
  * ]);`
  *
  * @return mixed The return of the other shell.
  * @link http://book.cakephp.org/3.0/en/console-and-shells.html#invoking-other-shells-from-your-shell
  */
 public function dispatchShell()
 {
     list($args, $extra) = $this->parseDispatchArguments(func_get_args());
     if (!isset($extra['requested'])) {
         $extra['requested'] = true;
     }
     $dispatcher = new ShellDispatcher($args, false);
     return $dispatcher->dispatch($extra);
 }
Exemplo n.º 3
0
 /**
  * Test finding a shell that has a matching alias.
  *
  * Aliases should not overload concrete shells.
  *
  * @return void
  */
 public function testFindShellAliasedAppShadow()
 {
     ShellDispatcher::alias('sample', 'test_plugin.example');
     $result = $this->dispatcher->findShell('sample');
     $this->assertInstanceOf('TestApp\\Shell\\SampleShell', $result);
     $this->assertEmpty($result->plugin);
     $this->assertEquals('Sample', $result->name);
 }
Exemplo n.º 4
0
 /**
  * Dispatch a command to another Shell. Similar to Object::requestAction()
  * but intended for running shells from other shells.
  *
  * ### Usage:
  *
  * With a string command:
  *
  * ```
  * return $this->dispatchShell('schema create DbAcl');
  * ```
  *
  * Avoid using this form if you have string arguments, with spaces in them.
  * The dispatched will be invoked incorrectly. Only use this form for simple
  * command dispatching.
  *
  * With an array command:
  *
  * ```
  * return $this->dispatchShell('schema', 'create', 'i18n', '--dry');
  * ```
  *
  * @return mixed The return of the other shell.
  * @link http://book.cakephp.org/3.0/en/console-and-shells.html#invoking-other-shells-from-your-shell
  */
 public function dispatchShell()
 {
     $args = func_get_args();
     if (is_string($args[0]) && count($args) === 1) {
         $args = explode(' ', $args[0]);
     }
     $dispatcher = new ShellDispatcher($args, false);
     return $dispatcher->dispatch();
 }
Exemplo n.º 5
0
 /**
  * Run the dispatcher
  *
  * @param array $argv The argv from PHP
  * @param array $extra Extra parameters
  * @return int The exit code of the shell process.
  */
 public static function run($argv, $extra = [])
 {
     $dispatcher = new ShellDispatcher($argv);
     return $dispatcher->dispatch($extra);
 }
Exemplo n.º 6
0
 /**
  * Run the dispatcher
  *
  * @param array $argv The argv from PHP
  * @return int The exit code of the shell process.
  */
 public static function run($argv)
 {
     $dispatcher = new ShellDispatcher($argv);
     return $dispatcher->dispatch();
 }