1
0
mirror of https://github.com/flarum/core.git synced 2025-08-02 14:37:49 +02:00

Restructure Flarum\Console namespace

This commit is contained in:
Franz Liedke
2017-06-24 11:29:44 +02:00
parent 9b24fbd5e5
commit c6985ae31c
7 changed files with 8 additions and 7 deletions

View File

@@ -9,7 +9,7 @@
* file that was distributed with this source code.
*/
namespace Flarum\Console\Command;
namespace Flarum\Console;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;

View File

@@ -1,105 +0,0 @@
<?php
/*
* This file is part of Flarum.
*
* (c) Toby Zerner <toby.zerner@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Flarum\Console\Command;
use Flarum\Database\MigrationCreator;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputOption;
class GenerateMigrationCommand extends AbstractCommand
{
/**
* @var MigrationCreator
*/
protected $creator;
/**
* @param MigrationCreator $creator
*/
public function __construct(MigrationCreator $creator)
{
parent::__construct();
$this->creator = $creator;
}
/**
* {@inheritdoc}
*/
protected function configure()
{
$this
->setName('generate:migration')
->setDescription('Generate a migration')
->addArgument(
'name',
InputArgument::REQUIRED,
'The name of the migration.'
)
->addOption(
'extension',
null,
InputOption::VALUE_REQUIRED,
'The extension to generate the migration for.'
)
->addOption(
'create',
null,
InputOption::VALUE_REQUIRED,
'The table to be created.'
)
->addOption(
'table',
null,
InputOption::VALUE_REQUIRED,
'The table to migrate.'
);
}
/**
* {@inheritdoc}
*/
protected function fire()
{
$name = $this->input->getArgument('name');
$extension = $this->input->getOption('extension');
$table = $this->input->getOption('table');
$create = $this->input->getOption('create');
if (! $table && is_string($create)) {
$table = $create;
}
$this->writeMigration($name, $extension, $table, $create);
}
/**
* Write the migration file to disk.
*
* @param string $name
* @param string $extension
* @param string $table
* @param bool $create
* @return string
*/
protected function writeMigration($name, $extension, $table, $create)
{
$path = $this->creator->create($name, $extension, $table, $create);
$file = pathinfo($path, PATHINFO_FILENAME);
$this->info("Created migration: $file");
}
}

View File

@@ -11,7 +11,7 @@
namespace Flarum\Console;
use Flarum\Console\Command\GenerateMigrationCommand;
use Flarum\Database\Console\GenerateMigrationCommand;
use Flarum\Debug\Console\CacheClearCommand;
use Flarum\Debug\Console\InfoCommand;
use Flarum\Foundation\AbstractServer;