Skip to content

Commit

Permalink
Move all framework command registration into ArtisanServiceProvider.
Browse files Browse the repository at this point in the history
Before this, commands were registered into the container all over the
place. Most were registered in ArtisanServiceProvider. This simply
moves the remaining commands into that class so every command is
registered in a single place across the framework, though the command
code itself can live in the component.
  • Loading branch information
taylorotwell committed Dec 19, 2016
1 parent baa6054 commit 954a333
Show file tree
Hide file tree
Showing 7 changed files with 252 additions and 289 deletions.
25 changes: 0 additions & 25 deletions src/Illuminate/Cache/CacheServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
namespace Illuminate\Cache;

use Illuminate\Support\ServiceProvider;
use Illuminate\Cache\Console\ClearCommand;
use Illuminate\Cache\Console\ForgetCommand;

class CacheServiceProvider extends ServiceProvider
{
Expand Down Expand Up @@ -33,28 +31,6 @@ public function register()
$this->app->singleton('memcached.connector', function () {
return new MemcachedConnector;
});

$this->registerCommands();
}

/**
* Register the cache related console commands.
*
* @return void
*/
public function registerCommands()
{
$this->app->singleton('command.cache.clear', function ($app) {
return new ClearCommand($app['cache']);
});

$this->commands('command.cache.clear');

$this->app->singleton('command.cache.forget', function ($app) {
return new ForgetCommand($app['cache']);
});

$this->commands('command.cache.forget');
}

/**
Expand All @@ -66,7 +42,6 @@ public function provides()
{
return [
'cache', 'cache.store', 'memcached.connector',
'command.cache.clear', 'command.cache.forget',
];
}
}
41 changes: 0 additions & 41 deletions src/Illuminate/Console/ScheduleServiceProvider.php

This file was deleted.

115 changes: 1 addition & 114 deletions src/Illuminate/Database/MigrationServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,6 @@
use Illuminate\Support\ServiceProvider;
use Illuminate\Database\Migrations\Migrator;
use Illuminate\Database\Migrations\MigrationCreator;
use Illuminate\Database\Console\Migrations\ResetCommand;
use Illuminate\Database\Console\Migrations\StatusCommand;
use Illuminate\Database\Console\Migrations\InstallCommand;
use Illuminate\Database\Console\Migrations\MigrateCommand;
use Illuminate\Database\Console\Migrations\RefreshCommand;
use Illuminate\Database\Console\Migrations\RollbackCommand;
use Illuminate\Database\Migrations\DatabaseMigrationRepository;

class MigrationServiceProvider extends ServiceProvider
Expand All @@ -31,14 +25,9 @@ public function register()
{
$this->registerRepository();

// Once we have registered the migrator instance we will go ahead and register
// all of the migration related commands that are used by the "Artisan" CLI
// so that they may be easily accessed for registering with the consoles.
$this->registerMigrator();

$this->registerCreator();

$this->registerCommands();
}

/**
Expand Down Expand Up @@ -84,105 +73,6 @@ protected function registerCreator()
});
}

/**
* Register all of the migration commands.
*
* @return void
*/
protected function registerCommands()
{
$commands = ['Migrate', 'Rollback', 'Reset', 'Refresh', 'Install', 'Status'];

// We'll simply spin through the list of commands that are migration related
// and register each one of them with an application container. They will
// be resolved in the Artisan start file and registered on the console.
foreach ($commands as $command) {
$this->{'register'.$command.'Command'}();
}

// Once the commands are registered in the application IoC container we will
// register them with the Artisan start event so that these are available
// when the Artisan application actually starts up and is getting used.
$this->commands(
'command.migrate',
'command.migrate.install', 'command.migrate.rollback',
'command.migrate.reset', 'command.migrate.refresh',
'command.migrate.status'
);
}

/**
* Register the "migrate" migration command.
*
* @return void
*/
protected function registerMigrateCommand()
{
$this->app->singleton('command.migrate', function ($app) {
return new MigrateCommand($app['migrator']);
});
}

/**
* Register the "rollback" migration command.
*
* @return void
*/
protected function registerRollbackCommand()
{
$this->app->singleton('command.migrate.rollback', function ($app) {
return new RollbackCommand($app['migrator']);
});
}

/**
* Register the "reset" migration command.
*
* @return void
*/
protected function registerResetCommand()
{
$this->app->singleton('command.migrate.reset', function ($app) {
return new ResetCommand($app['migrator']);
});
}

/**
* Register the "refresh" migration command.
*
* @return void
*/
protected function registerRefreshCommand()
{
$this->app->singleton('command.migrate.refresh', function () {
return new RefreshCommand;
});
}

/**
* Register the "status" migration command.
*
* @return void
*/
protected function registerStatusCommand()
{
$this->app->singleton('command.migrate.status', function ($app) {
return new StatusCommand($app['migrator']);
});
}

/**
* Register the "install" migration command.
*
* @return void
*/
protected function registerInstallCommand()
{
$this->app->singleton('command.migrate.install', function ($app) {
return new InstallCommand($app['migration.repository']);
});
}

/**
* Get the services provided by the provider.
*
Expand All @@ -191,10 +81,7 @@ protected function registerInstallCommand()
public function provides()
{
return [
'migrator', 'migration.repository', 'command.migrate',
'command.migrate.rollback', 'command.migrate.reset',
'command.migrate.refresh', 'command.migrate.install',
'command.migrate.status', 'migration.creator',
'migrator', 'migration.repository', 'migration.creator',
];
}
}
50 changes: 0 additions & 50 deletions src/Illuminate/Database/SeedServiceProvider.php

This file was deleted.

Loading

0 comments on commit 954a333

Please sign in to comment.