From 925ef227a3adc6a5b6d0207d0fa8f96e524d16ea Mon Sep 17 00:00:00 2001 From: Franz Liedke Date: Sat, 24 Jun 2017 11:34:29 +0200 Subject: [PATCH] Restructure Flarum\Database namespace --- framework/core/src/Console/Server.php | 2 +- .../Console/MigrateCommand.php | 2 +- .../src/Database/DatabaseServiceProvider.php | 9 ------ .../src/Database/MigrationServiceProvider.php | 32 +++++++++++++++++++ .../Update/Controller/UpdateController.php | 2 +- 5 files changed, 35 insertions(+), 12 deletions(-) rename framework/core/src/{Update => Database}/Console/MigrateCommand.php (98%) create mode 100644 framework/core/src/Database/MigrationServiceProvider.php diff --git a/framework/core/src/Console/Server.php b/framework/core/src/Console/Server.php index ecbf3f8ab..d18533e42 100644 --- a/framework/core/src/Console/Server.php +++ b/framework/core/src/Console/Server.php @@ -16,7 +16,7 @@ use Flarum\Debug\Console\CacheClearCommand; use Flarum\Debug\Console\InfoCommand; use Flarum\Foundation\AbstractServer; use Flarum\Install\Console\InstallCommand; -use Flarum\Update\Console\MigrateCommand; +use Flarum\Database\Console\MigrateCommand; use Symfony\Component\Console\Application; class Server extends AbstractServer diff --git a/framework/core/src/Update/Console/MigrateCommand.php b/framework/core/src/Database/Console/MigrateCommand.php similarity index 98% rename from framework/core/src/Update/Console/MigrateCommand.php rename to framework/core/src/Database/Console/MigrateCommand.php index bdff208c0..f5782d13f 100644 --- a/framework/core/src/Update/Console/MigrateCommand.php +++ b/framework/core/src/Database/Console/MigrateCommand.php @@ -9,7 +9,7 @@ * file that was distributed with this source code. */ -namespace Flarum\Update\Console; +namespace Flarum\Database\Console; use Flarum\Console\AbstractCommand; use Illuminate\Contracts\Container\Container; diff --git a/framework/core/src/Database/DatabaseServiceProvider.php b/framework/core/src/Database/DatabaseServiceProvider.php index 87324330c..c4b349074 100644 --- a/framework/core/src/Database/DatabaseServiceProvider.php +++ b/framework/core/src/Database/DatabaseServiceProvider.php @@ -12,7 +12,6 @@ namespace Flarum\Database; use Flarum\Foundation\AbstractServiceProvider; -use Flarum\Foundation\Application; use Illuminate\Database\ConnectionResolver; use Illuminate\Database\Connectors\ConnectionFactory; use PDO; @@ -46,14 +45,6 @@ class DatabaseServiceProvider extends AbstractServiceProvider }); $this->app->alias('Illuminate\Database\ConnectionResolverInterface', 'db'); - - $this->app->singleton('Flarum\Database\MigrationRepositoryInterface', function ($app) { - return new DatabaseMigrationRepository($app['db'], 'migrations'); - }); - - $this->app->bind(MigrationCreator::class, function (Application $app) { - return new MigrationCreator($app->make('Illuminate\Filesystem\Filesystem'), $app->basePath()); - }); } /** diff --git a/framework/core/src/Database/MigrationServiceProvider.php b/framework/core/src/Database/MigrationServiceProvider.php new file mode 100644 index 000000000..5a21c9ada --- /dev/null +++ b/framework/core/src/Database/MigrationServiceProvider.php @@ -0,0 +1,32 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Flarum\Database; + +use Flarum\Foundation\AbstractServiceProvider; +use Flarum\Foundation\Application; + +class MigrationServiceProvider extends AbstractServiceProvider +{ + /** + * {@inheritdoc} + */ + public function register() + { + $this->app->singleton('Flarum\Database\MigrationRepositoryInterface', function ($app) { + return new DatabaseMigrationRepository($app['db'], 'migrations'); + }); + + $this->app->bind(MigrationCreator::class, function (Application $app) { + return new MigrationCreator($app->make('Illuminate\Filesystem\Filesystem'), $app->basePath()); + }); + } +} diff --git a/framework/core/src/Update/Controller/UpdateController.php b/framework/core/src/Update/Controller/UpdateController.php index 9b20ede72..2a0335030 100644 --- a/framework/core/src/Update/Controller/UpdateController.php +++ b/framework/core/src/Update/Controller/UpdateController.php @@ -14,7 +14,7 @@ namespace Flarum\Update\Controller; use Exception; use Flarum\Foundation\Application; use Flarum\Http\Controller\ControllerInterface; -use Flarum\Update\Console\MigrateCommand; +use Flarum\Database\Console\MigrateCommand; use Psr\Http\Message\ServerRequestInterface as Request; use Symfony\Component\Console\Input\StringInput; use Symfony\Component\Console\Output\StreamOutput;