-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
lazyload migrations when command is run
- Loading branch information
1 parent
22d4859
commit bd61d88
Showing
8 changed files
with
155 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
<?php | ||
|
||
/** | ||
* This file is part of Zenify | ||
* Copyright (c) 2014 Tomas Votruba (http://tomasvotruba.cz) | ||
*/ | ||
|
||
namespace Zenify\DoctrineMigrations\EventSubscriber; | ||
|
||
use Doctrine\DBAL\Migrations\Configuration\Configuration; | ||
use Doctrine\DBAL\Migrations\Tools\Console\Command\AbstractCommand; | ||
use Kdyby\Events\Subscriber; | ||
use Symfony\Component\Console\Command\Command; | ||
use Symfony\Component\Console\ConsoleEvents; | ||
use Symfony\Component\Console\Event\ConsoleCommandEvent; | ||
|
||
|
||
final class RegisterMigrationsEventSubscriber implements Subscriber | ||
{ | ||
|
||
/** | ||
* @var Configuration | ||
*/ | ||
private $configuration; | ||
|
||
|
||
public function __construct(Configuration $configuration) | ||
{ | ||
$this->configuration = $configuration; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function getSubscribedEvents() | ||
{ | ||
return [ConsoleEvents::COMMAND => 'registerMigrations']; | ||
} | ||
|
||
|
||
public function registerMigrations(ConsoleCommandEvent $event) | ||
{ | ||
$command = $event->getCommand(); | ||
if ( ! $this->isMigrationCommand($command)) { | ||
return; | ||
} | ||
|
||
$this->configuration->registerMigrationsFromDirectory( | ||
$this->configuration->getMigrationsDirectory() | ||
); | ||
} | ||
|
||
|
||
/** | ||
* @return bool | ||
*/ | ||
private function isMigrationCommand(Command $command) | ||
{ | ||
return $command instanceof AbstractCommand; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<?php | ||
|
||
namespace Zenify\DoctrineMigrations\Tests\Migrations; | ||
|
||
use Doctrine\DBAL\Migrations\AbstractMigration; | ||
use Doctrine\DBAL\Schema\Schema; | ||
|
||
|
||
final class Version546 extends AbstractMigration | ||
{ | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function up(Schema $schema) | ||
{ | ||
} | ||
|
||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function down(Schema $schema) | ||
{ | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters