refactoring the cli.
This commit is contained in:
parent
611f8d7e1b
commit
8cfb6d621c
|
@ -17,31 +17,7 @@
|
||||||
* us to seamlessly add tasks to the CLI so that the Task class
|
* us to seamlessly add tasks to the CLI so that the Task class
|
||||||
* doesn't have to worry about how to resolve core tasks.
|
* doesn't have to worry about how to resolve core tasks.
|
||||||
*/
|
*/
|
||||||
|
require SYS_PATH.'cli/dependencies'.EXT;
|
||||||
/**
|
|
||||||
* The bundle task is responsible for the installation of bundles
|
|
||||||
* and their dependencies. It utilizes the bundles API to get the
|
|
||||||
* meta-data for the available bundles.
|
|
||||||
*/
|
|
||||||
IoC::register('task: bundle', function()
|
|
||||||
{
|
|
||||||
return new Tasks\Bundle\Bundler;
|
|
||||||
});
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The migrate task is responsible for running database migrations
|
|
||||||
* as well as migration rollbacks. We will also create an instance
|
|
||||||
* of the migration resolver and database classes, which are used
|
|
||||||
* to perform various support functions for the migrator.
|
|
||||||
*/
|
|
||||||
IoC::register('task: migrate', function()
|
|
||||||
{
|
|
||||||
$database = new Tasks\Migrate\Database;
|
|
||||||
|
|
||||||
$resolver = new Tasks\Migrate\Resolver($database);
|
|
||||||
|
|
||||||
return new Tasks\Migrate\Migrator($resolver, $database);
|
|
||||||
});
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* We will wrap the command execution in a try / catch block and
|
* We will wrap the command execution in a try / catch block and
|
||||||
|
|
|
@ -27,6 +27,9 @@ public static function run($arguments = array())
|
||||||
// via the container instead of by this class.
|
// via the container instead of by this class.
|
||||||
if (Bundle::exists($bundle)) Bundle::start($bundle);
|
if (Bundle::exists($bundle)) Bundle::start($bundle);
|
||||||
|
|
||||||
|
// Once the bundle has been started, we will attempt to resolve the
|
||||||
|
// task instance. Tasks may be resolved through the file system or
|
||||||
|
// through the application IoC container.
|
||||||
if (is_null($task = static::resolve($bundle, $task)))
|
if (is_null($task = static::resolve($bundle, $task)))
|
||||||
{
|
{
|
||||||
throw new \Exception("Sorry, I can't find that task.");
|
throw new \Exception("Sorry, I can't find that task.");
|
||||||
|
@ -47,7 +50,7 @@ protected static function parse($task)
|
||||||
|
|
||||||
// Extract the task method from the task string. Methods are called
|
// Extract the task method from the task string. Methods are called
|
||||||
// on tasks by separating the task and method with a single colon.
|
// on tasks by separating the task and method with a single colon.
|
||||||
// If no task is specified, "run" is used as the default method.
|
// If no task is specified, "run" is used as the default.
|
||||||
if (str_contains($task, ':'))
|
if (str_contains($task, ':'))
|
||||||
{
|
{
|
||||||
list($task, $method) = explode(':', $task);
|
list($task, $method) = explode(':', $task);
|
||||||
|
|
|
@ -0,0 +1,57 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The migrate task is responsible for running database migrations
|
||||||
|
* as well as migration rollbacks. We will also create an instance
|
||||||
|
* of the migration resolver and database classes, which are used
|
||||||
|
* to perform various support functions for the migrator.
|
||||||
|
*/
|
||||||
|
IoC::register('task: migrate', function()
|
||||||
|
{
|
||||||
|
$database = new Tasks\Migrate\Database;
|
||||||
|
|
||||||
|
$resolver = new Tasks\Migrate\Resolver($database);
|
||||||
|
|
||||||
|
return new Tasks\Migrate\Migrator($resolver, $database);
|
||||||
|
});
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The bundle task is responsible for the installation of bundles
|
||||||
|
* and their dependencies. It utilizes the bundles API to get the
|
||||||
|
* meta-data for the available bundles.
|
||||||
|
*/
|
||||||
|
IoC::register('task: bundle', function()
|
||||||
|
{
|
||||||
|
return new Tasks\Bundle\Bundler;
|
||||||
|
});
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The bundle repository is responsible for communicating with
|
||||||
|
* the Laravel bundle sources to get information regarding any
|
||||||
|
* bundles that are requested for installation.
|
||||||
|
*/
|
||||||
|
IoC::singleton('bundle.repository', function()
|
||||||
|
{
|
||||||
|
return new Repository;
|
||||||
|
});
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The bundle publisher is responsible for publishing bundle
|
||||||
|
* assets and tests to their correct directories within the
|
||||||
|
* application, such as the web accessible directory.
|
||||||
|
*/
|
||||||
|
IoC::singleton('bundle.publisher', function()
|
||||||
|
{
|
||||||
|
return new Publisher;
|
||||||
|
});
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The Github bundle provider installs bundles that live on
|
||||||
|
* Github. This provider will add the bundle as a submodule
|
||||||
|
* and will update the submodule so that the bundle is
|
||||||
|
* installed into the bundle directory.
|
||||||
|
*/
|
||||||
|
IoC::singleton('bundle.provider: github', function()
|
||||||
|
{
|
||||||
|
return new Providers\Github;
|
||||||
|
});
|
|
@ -4,21 +4,6 @@
|
||||||
use Laravel\Bundle;
|
use Laravel\Bundle;
|
||||||
use Laravel\CLI\Tasks\Task;
|
use Laravel\CLI\Tasks\Task;
|
||||||
|
|
||||||
IoC::singleton('bundle.repository', function()
|
|
||||||
{
|
|
||||||
return new Repository;
|
|
||||||
});
|
|
||||||
|
|
||||||
IoC::singleton('bundle.publisher', function()
|
|
||||||
{
|
|
||||||
return new Publisher;
|
|
||||||
});
|
|
||||||
|
|
||||||
IoC::singleton('bundle.provider: github', function()
|
|
||||||
{
|
|
||||||
return new Providers\Github;
|
|
||||||
});
|
|
||||||
|
|
||||||
class Bundler extends Task {
|
class Bundler extends Task {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue