Skip to content

Commit

Permalink
Fix nette injects in execute command (#22) (#30)
Browse files Browse the repository at this point in the history
  • Loading branch information
Rixafy authored Jan 31, 2021
1 parent dd5a0ca commit 71951f6
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 3 deletions.
26 changes: 26 additions & 0 deletions src/Command/FixedExecuteCommand.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php declare(strict_types = 1);

namespace Nettrine\Migrations\Command;

use Doctrine\Migrations\Tools\Console\Command\ExecuteCommand;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;

class FixedExecuteCommand extends ExecuteCommand
{

public function getName(): string
{
return self::$defaultName;
}

public function execute(InputInterface $input, OutputInterface $output): ?int
{
$version = $input->getArgument('version');
assert(is_string($version));
$this->configuration->getVersion($version);

return parent::execute($input, $output);
}

}
4 changes: 2 additions & 2 deletions src/DI/MigrationsExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
namespace Nettrine\Migrations\DI;

use Doctrine\Migrations\Tools\Console\Command\DiffCommand;
use Doctrine\Migrations\Tools\Console\Command\ExecuteCommand;
use Doctrine\Migrations\Tools\Console\Command\GenerateCommand;
use Doctrine\Migrations\Tools\Console\Command\LatestCommand;
use Doctrine\Migrations\Tools\Console\Command\MigrateCommand;
Expand All @@ -16,6 +15,7 @@
use Nette\DI\Definitions\Statement;
use Nette\Schema\Expect;
use Nette\Schema\Schema;
use Nettrine\Migrations\Command\FixedExecuteCommand;
use Nettrine\Migrations\ContainerAwareConfiguration;
use stdClass;
use Symfony\Component\Console\Application;
Expand Down Expand Up @@ -70,7 +70,7 @@ public function loadConfiguration(): void
->setAutowired(false)
->addTag('console.command', 'migrations:diff');
$builder->addDefinition($this->prefix('executeCommand'))
->setFactory(ExecuteCommand::class)
->setFactory(FixedExecuteCommand::class)
->setAutowired(false)
->addTag('console.command', 'migrations:execute');
$builder->addDefinition($this->prefix('generateCommand'))
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php declare(strict_types = 1);

namespace Nettrine\Migrations\Events;
namespace Nettrine\Migrations\Subscriber;

use Doctrine\Common\EventSubscriber;
use Doctrine\DBAL\Schema\PostgreSqlSchemaManager;
Expand Down

0 comments on commit 71951f6

Please sign in to comment.