Skip to content

Commit 77230e1

Browse files
committed
backport symfony 2.3
1 parent 0ddcfbd commit 77230e1

File tree

4 files changed

+18
-52
lines changed

4 files changed

+18
-52
lines changed

Command/InitializeCommand.php

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,22 +11,14 @@
1111

1212
namespace DTL\Bundle\PhpcrMigrations\Command;
1313

14-
use PHPCR\Migrations\MigratorFactory;
15-
use Symfony\Component\Console\Command\Command;
14+
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
1615
use Symfony\Component\Console\Input\InputInterface;
1716
use Symfony\Component\Console\Output\OutputInterface;
1817

19-
class InitializeCommand extends Command
18+
class InitializeCommand extends ContainerAwareCommand
2019
{
2120
private $factory;
2221

23-
public function __construct(
24-
MigratorFactory $factory
25-
) {
26-
parent::__construct();
27-
$this->factory = $factory;
28-
}
29-
3022
public function configure()
3123
{
3224
$this->setName('phpcr:migrations:initialize');
@@ -42,6 +34,7 @@ public function configure()
4234

4335
public function execute(InputInterface $input, OutputInterface $output)
4436
{
37+
$this->factory = $this->getContainer()->get('phpcr_migrations.migrator_factory');
4538
$this->factory->getMigrator()->initialize();
4639
}
4740
}

Command/MigrateCommand.php

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -11,31 +11,20 @@
1111

1212
namespace DTL\Bundle\PhpcrMigrations\Command;
1313

14-
use PHPCR\Migrations\MigratorFactory;
15-
use Symfony\Component\Console\Command\Command;
14+
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
1615
use Symfony\Component\Console\Input\InputArgument;
1716
use Symfony\Component\Console\Input\InputInterface;
1817
use Symfony\Component\Console\Output\OutputInterface;
1918
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
2019
use Symfony\Component\DependencyInjection\ContainerInterface;
2120

22-
class MigrateCommand extends Command
21+
class MigrateCommand extends ContainerAwareCommand
2322
{
2423
private $factory;
25-
private $container;
2624
private $actions = array(
2725
'up', 'down', 'top', 'bottom',
2826
);
2927

30-
public function __construct(
31-
MigratorFactory $factory,
32-
ContainerInterface $container
33-
) {
34-
parent::__construct();
35-
$this->factory = $factory;
36-
$this->container = $container;
37-
}
38-
3928
public function configure()
4029
{
4130
$this->setName('phpcr:migrations:migrate');
@@ -72,12 +61,14 @@ public function configure()
7261

7362
public function execute(InputInterface $input, OutputInterface $output)
7463
{
64+
$this->factory = $this->getContainer()->get('phpcr_migrations.migrator_factory');
65+
7566
$to = $input->getArgument('to');
7667
$migrator = $this->factory->getMigrator();
7768

7869
foreach ($migrator->getVersions() as $version) {
7970
if ($version instanceof ContainerAwareInterface) {
80-
$version->setContainer($this->container);
71+
$version->setContainer($this->getContainer());
8172
}
8273
}
8374

Command/StatusCommand.php

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -11,26 +11,16 @@
1111

1212
namespace DTL\Bundle\PhpcrMigrations\Command;
1313

14-
use PHPCR\Migrations\VersionFinder;
15-
use PHPCR\Migrations\VersionStorage;
16-
use Symfony\Component\Console\Command\Command;
17-
use Symfony\Component\Console\Helper\Table;
14+
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
15+
use Symfony\Component\Console\Helper\TableHelper;
1816
use Symfony\Component\Console\Input\InputInterface;
1917
use Symfony\Component\Console\Output\OutputInterface;
2018

21-
class StatusCommand extends Command
19+
class StatusCommand extends ContainerAwareCommand
2220
{
2321
private $versionStorage;
2422
private $finder;
2523

26-
public function __construct(
27-
VersionStorage $versionStorage,
28-
VersionFinder $finder
29-
) {
30-
parent::__construct();
31-
$this->versionStorage = $versionStorage;
32-
$this->finder = $finder;
33-
}
3424

3525
public function configure()
3626
{
@@ -50,11 +40,14 @@ public function configure()
5040

5141
public function execute(InputInterface $input, OutputInterface $output)
5242
{
43+
$this->versionStorage = $this->getContainer()->get('phpcr_migrations.version_storage');
44+
$this->finder = $this->getContainer()->get('phpcr_migrations.version_finder');
45+
5346
$versionCollection = $this->finder->getCollection();
5447
$executedVersions = (array) $this->versionStorage->getPersistedVersions();
5548
$currentVersion = $this->versionStorage->getCurrentVersion();
5649

57-
$table = new Table($output);
50+
$table = new TableHelper();
5851
$table->setHeaders(array(
5952
'', 'Version', 'Date', 'Migrated', 'Path',
6053
));
@@ -70,7 +63,7 @@ public function execute(InputInterface $input, OutputInterface $output)
7063
));
7164
}
7265

73-
$table->render();
66+
$table->render($output);
7467

7568
if ($currentVersion) {
7669
$output->writeln(sprintf('<info>Current:</info> %s (%s)', $currentVersion, $this->getDate($currentVersion)));

Resources/config/services.xml

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@
44
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
55

66
<services>
7-
<service id="phpcr_migrations.version_storage" class="PHPCR\Migrations\VersionStorage" public="false">
7+
<service id="phpcr_migrations.version_storage" class="PHPCR\Migrations\VersionStorage">
88
<argument type="service" id="doctrine_phpcr.default_session" />
99
<argument>%phpcr_migrations.version_node_name%</argument>
1010
</service>
1111

12-
<service id="phpcr_migrations.version_finder" class="PHPCR\Migrations\VersionFinder" public="false">
12+
<service id="phpcr_migrations.version_finder" class="PHPCR\Migrations\VersionFinder">
1313
<argument>%phpcr_migrations.paths%</argument>
1414
</service>
1515

@@ -19,23 +19,12 @@
1919
<argument type="service" id="doctrine_phpcr.default_session" />
2020
</service>
2121

22-
<service id="phpcr_migrations.command.status" class="DTL\Bundle\PhpcrMigrations\Command\StatusCommand">
23-
<argument type="service" id="phpcr_migrations.version_storage" />
24-
<argument type="service" id="phpcr_migrations.version_finder" />
25-
<tag name="console.command" />
26-
</service>
27-
2822
<service id="phpcr_migrations.command.migrate" class="DTL\Bundle\PhpcrMigrations\Command\MigrateCommand">
2923
<argument type="service" id="phpcr_migrations.migrator_factory" />
3024
<argument type="service" id="service_container" />
3125
<tag name="console.command" />
3226
</service>
3327

34-
<service id="phpcr_migrations.command.initialize" class="DTL\Bundle\PhpcrMigrations\Command\InitializeCommand">
35-
<argument type="service" id="phpcr_migrations.migrator_factory" />
36-
<tag name="console.command" />
37-
</service>
38-
3928
<service id="phpcr_migrations.migrator_factory" class="PHPCR\Migrations\MigratorFactory">
4029
<argument type="service" id="phpcr_migrations.version_storage" />
4130
<argument type="service" id="phpcr_migrations.version_finder" />

0 commit comments

Comments
 (0)