Skip to content
This repository was archived by the owner on Jan 10, 2023. It is now read-only.

Commit 14cff6f

Browse files
viktorproggerarrilot
authored andcommitted
Позволяем задавать кастомные имена командам (#22)
* Позволяем задавать кастомные имена командам * Имена по умолчанию делаем именами по умолчанию
1 parent a31d18b commit 14cff6f

File tree

7 files changed

+45
-29
lines changed

7 files changed

+45
-29
lines changed

src/Commands/ArchiveCommand.php

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,26 +13,27 @@ class ArchiveCommand extends AbstractCommand
1313
* @var Migrator
1414
*/
1515
protected $migrator;
16+
protected static $defaultName = 'archive';
1617

1718
/**
1819
* Constructor.
1920
*
20-
* @param Migrator $migrator
21+
* @param Migrator $migrator
22+
* @param string|null $name
2123
*/
22-
public function __construct(Migrator $migrator)
24+
public function __construct(Migrator $migrator, $name = null)
2325
{
2426
$this->migrator = $migrator;
2527

26-
parent::__construct();
28+
parent::__construct($name);
2729
}
2830

2931
/**
3032
* Configures the current command.
3133
*/
3234
protected function configure()
3335
{
34-
$this->setName('archive')
35-
->setDescription('Move migration into archive')
36+
$this->setDescription('Move migration into archive')
3637
->addOption('without', 'w', InputOption::VALUE_REQUIRED, 'Archive without last N migration');
3738
}
3839

src/Commands/InstallCommand.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,26 +20,29 @@ class InstallCommand extends AbstractCommand
2020
*/
2121
protected $table;
2222

23+
protected static $defaultName = 'install';
24+
2325
/**
2426
* Constructor.
2527
*
2628
* @param string $table
2729
* @param DatabaseStorageInterface $database
30+
* @param string|null $name
2831
*/
29-
public function __construct($table, DatabaseStorageInterface $database)
32+
public function __construct($table, DatabaseStorageInterface $database, $name = null)
3033
{
3134
$this->table = $table;
3235
$this->database = $database;
3336

34-
parent::__construct();
37+
parent::__construct($name);
3538
}
3639

3740
/**
3841
* Configures the current command.
3942
*/
4043
protected function configure()
4144
{
42-
$this->setName('install')->setDescription('Create the migration database table');
45+
$this->setDescription('Create the migration database table');
4346
}
4447

4548
/**

src/Commands/MakeCommand.php

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,25 +15,27 @@ class MakeCommand extends AbstractCommand
1515
*/
1616
protected $migrator;
1717

18+
protected static $defaultName = 'make';
19+
1820
/**
1921
* Constructor.
2022
*
21-
* @param Migrator $migrator
23+
* @param Migrator $migrator
24+
* @param string|null $name
2225
*/
23-
public function __construct(Migrator $migrator)
26+
public function __construct(Migrator $migrator, $name = null)
2427
{
2528
$this->migrator = $migrator;
2629

27-
parent::__construct();
30+
parent::__construct($name);
2831
}
2932

3033
/**
3134
* Configures the current command.
3235
*/
3336
protected function configure()
3437
{
35-
$this->setName('make')
36-
->setDescription('Create a new migration file')
38+
$this->setDescription('Create a new migration file')
3739
->addArgument(
3840
'name',
3941
InputArgument::REQUIRED,

src/Commands/MigrateCommand.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,24 +13,26 @@ class MigrateCommand extends AbstractCommand
1313
*/
1414
protected $migrator;
1515

16+
protected static $defaultName = 'migrate';
1617
/**
1718
* Constructor.
1819
*
19-
* @param Migrator $migrator
20+
* @param Migrator $migrator
21+
* @param string|null $name
2022
*/
21-
public function __construct(Migrator $migrator)
23+
public function __construct(Migrator $migrator, $name = null)
2224
{
2325
$this->migrator = $migrator;
2426

25-
parent::__construct();
27+
parent::__construct($name);
2628
}
2729

2830
/**
2931
* Configures the current command.
3032
*/
3133
protected function configure()
3234
{
33-
$this->setName('migrate')->setDescription('Run all outstanding migrations');
35+
$this->setDescription('Run all outstanding migrations');
3436
}
3537

3638
/**

src/Commands/RollbackCommand.php

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,25 +15,27 @@ class RollbackCommand extends AbstractCommand
1515
*/
1616
protected $migrator;
1717

18+
protected static $defaultName = 'rollback';
19+
1820
/**
1921
* Constructor.
2022
*
21-
* @param Migrator $migrator
23+
* @param Migrator $migrator
24+
* @param string|null $name
2225
*/
23-
public function __construct(Migrator $migrator)
26+
public function __construct(Migrator $migrator, $name = null)
2427
{
2528
$this->migrator = $migrator;
2629

27-
parent::__construct();
30+
parent::__construct($name);
2831
}
2932

3033
/**
3134
* Configures the current command.
3235
*/
3336
protected function configure()
3437
{
35-
$this->setName('rollback')
36-
->setDescription('Rollback the last migration')
38+
$this->setDescription('Rollback the last migration')
3739
->addOption('hard', null, InputOption::VALUE_NONE, 'Rollback without running down()')
3840
->addOption('delete', null, InputOption::VALUE_NONE, 'Delete migration file after rolling back');
3941
}

src/Commands/StatusCommand.php

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,24 +13,27 @@ class StatusCommand extends AbstractCommand
1313
*/
1414
protected $migrator;
1515

16+
protected static $defaultName = 'status';
17+
1618
/**
1719
* Constructor.
1820
*
19-
* @param Migrator $migrator
21+
* @param Migrator $migrator
22+
* @param string|null $name
2023
*/
21-
public function __construct(Migrator $migrator)
24+
public function __construct(Migrator $migrator, $name = null)
2225
{
2326
$this->migrator = $migrator;
2427

25-
parent::__construct();
28+
parent::__construct($name);
2629
}
2730

2831
/**
2932
* Configures the current command.
3033
*/
3134
protected function configure()
3235
{
33-
$this->setName('status')->setDescription('Show status about last migrations');
36+
$this->setDescription('Show status about last migrations');
3437
}
3538

3639
/**

src/Commands/TemplatesCommand.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,24 +15,27 @@ class TemplatesCommand extends AbstractCommand
1515
*/
1616
protected $collection;
1717

18+
protected static $defaultName = 'templates';
19+
1820
/**
1921
* Constructor.
2022
*
2123
* @param TemplatesCollection $collection
24+
* @param string|null $name
2225
*/
23-
public function __construct(TemplatesCollection $collection)
26+
public function __construct(TemplatesCollection $collection, $name = null)
2427
{
2528
$this->collection = $collection;
2629

27-
parent::__construct();
30+
parent::__construct($name);
2831
}
2932

3033
/**
3134
* Configures the current command.
3235
*/
3336
protected function configure()
3437
{
35-
$this->setName('templates')->setDescription('Show the list of available migration templates');
38+
$this->setDescription('Show the list of available migration templates');
3639
}
3740

3841
/**

0 commit comments

Comments
 (0)