Skip to content

Commit a2a3b89

Browse files
authored
Merge pull request #10 from dantleech/revert-2-backport_1_0
Revert "Backport "
2 parents 2ea5af8 + 0c0c01f commit a2a3b89

File tree

9 files changed

+75
-50
lines changed

9 files changed

+75
-50
lines changed

.travis.yml

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,12 @@
11
language: php
22

33
php:
4-
- 5.4
5-
- 5.5
64
- 5.6
5+
- 7.0
76

87
env:
9-
- SYMFONY_VERSION=2.3.*
10-
- SYMFONY_VERSION=2.4.*
11-
- SYMFONY_VERSION=2.5.*
12-
- SYMFONY_VERSION=2.6.*
8+
- SYMFONY_VERSION=2.8.*
9+
- SYMFONY_VERSION=3.0.*
1310
- SYMFONY_VERSION=dev-master
1411

1512
before_script:

Command/InitializeCommand.php

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

1212
namespace DTL\Bundle\PhpcrMigrations\Command;
1313

14-
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
14+
use PHPCR\Migrations\MigratorFactory;
15+
use Symfony\Component\Console\Command\Command;
1516
use Symfony\Component\Console\Input\InputInterface;
1617
use Symfony\Component\Console\Output\OutputInterface;
1718

18-
class InitializeCommand extends ContainerAwareCommand
19+
class InitializeCommand extends Command
1920
{
2021
private $factory;
2122

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

3543
public function execute(InputInterface $input, OutputInterface $output)
3644
{
37-
$this->factory = $this->getContainer()->get('phpcr_migrations.migrator_factory');
3845
$this->factory->getMigrator()->initialize();
3946
}
4047
}

Command/MigrateCommand.php

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

1212
namespace DTL\Bundle\PhpcrMigrations\Command;
1313

14-
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
14+
use PHPCR\Migrations\MigratorFactory;
15+
use Symfony\Component\Console\Command\Command;
1516
use Symfony\Component\Console\Input\InputArgument;
1617
use Symfony\Component\Console\Input\InputInterface;
1718
use Symfony\Component\Console\Output\OutputInterface;
1819
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
1920
use Symfony\Component\DependencyInjection\ContainerInterface;
2021

21-
class MigrateCommand extends ContainerAwareCommand
22+
class MigrateCommand extends Command
2223
{
2324
private $factory;
25+
private $container;
2426
private $actions = array(
2527
'up', 'down', 'top', 'bottom',
2628
);
2729

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

6273
public function execute(InputInterface $input, OutputInterface $output)
6374
{
64-
$this->factory = $this->getContainer()->get('phpcr_migrations.migrator_factory');
65-
6675
$to = $input->getArgument('to');
6776
$migrator = $this->factory->getMigrator();
6877

6978
foreach ($migrator->getVersions() as $version) {
7079
if ($version instanceof ContainerAwareInterface) {
71-
$version->setContainer($this->getContainer());
80+
$version->setContainer($this->container);
7281
}
7382
}
7483

Command/StatusCommand.php

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

1212
namespace DTL\Bundle\PhpcrMigrations\Command;
1313

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

19-
class StatusCommand extends ContainerAwareCommand
21+
class StatusCommand extends Command
2022
{
2123
private $versionStorage;
2224
private $finder;
2325

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

2535
public function configure()
2636
{
@@ -40,14 +50,11 @@ public function configure()
4050

4151
public function execute(InputInterface $input, OutputInterface $output)
4252
{
43-
$this->versionStorage = $this->getContainer()->get('phpcr_migrations.version_storage');
44-
$this->finder = $this->getContainer()->get('phpcr_migrations.version_finder');
45-
4653
$versionCollection = $this->finder->getCollection();
4754
$executedVersions = (array) $this->versionStorage->getPersistedVersions();
4855
$currentVersion = $this->versionStorage->getCurrentVersion();
4956

50-
$table = new TableHelper();
57+
$table = new Table($output);
5158
$table->setHeaders(array(
5259
'', 'Version', 'Date', 'Migrated', 'Path',
5360
));
@@ -63,7 +70,7 @@ public function execute(InputInterface $input, OutputInterface $output)
6370
));
6471
}
6572

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

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

Resources/config/services.xml

Lines changed: 19 additions & 2 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">
7+
<service id="phpcr_migrations.version_storage" class="PHPCR\Migrations\VersionStorage" public="false">
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">
12+
<service id="phpcr_migrations.version_finder" class="PHPCR\Migrations\VersionFinder" public="false">
1313
<argument>%phpcr_migrations.paths%</argument>
1414
</service>
1515

@@ -19,6 +19,23 @@
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+
28+
<service id="phpcr_migrations.command.migrate" class="DTL\Bundle\PhpcrMigrations\Command\MigrateCommand">
29+
<argument type="service" id="phpcr_migrations.migrator_factory" />
30+
<argument type="service" id="service_container" />
31+
<tag name="console.command" />
32+
</service>
33+
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+
2239
<service id="phpcr_migrations.migrator_factory" class="PHPCR\Migrations\MigratorFactory">
2340
<argument type="service" id="phpcr_migrations.version_storage" />
2441
<argument type="service" id="phpcr_migrations.version_finder" />

Tests/Functional/BaseTestCase.php

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@
1111

1212
namespace DTL\Bundle\PhpcrMigrations\Tests\Functional;
1313

14-
use DTL\Bundle\PhpcrMigrations\Command\MigrateCommand;
15-
use DTL\Bundle\PhpcrMigrations\Command\StatusCommand;
1614
use Symfony\Cmf\Component\Testing\Functional\BaseTestCase as CmfBaseTestCase;
1715
use Symfony\Component\Console\Tester\CommandTester;
1816

@@ -29,22 +27,12 @@ public function setUp()
2927
}
3028
}
3129

32-
protected function executeCommand($command, $arguments)
30+
protected function executeCommand($serviceId, $arguments)
3331
{
34-
$command->setContainer($this->getContainer());
32+
$command = $this->getContainer()->get($serviceId);
3533
$tester = new CommandTester($command);
3634
$tester->execute($arguments);
3735

3836
return $tester;
3937
}
40-
41-
protected function getMigrateCommand()
42-
{
43-
return new MigrateCommand();
44-
}
45-
46-
protected function getStatusCommand()
47-
{
48-
return new StatusCommand();
49-
}
5038
}

Tests/Functional/MigrateCommandTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class MigrateCommandTest extends BaseTestCase
1818
*/
1919
public function testMigrateToLatest()
2020
{
21-
$this->executeCommand($this->getMigrateCommand(), array());
21+
$this->executeCommand('phpcr_migrations.command.migrate', array());
2222

2323
$versionNodes = $this->session->getNode('/jcr:migrations')->getNodes();
2424
$this->assertCount(5, $versionNodes);
@@ -29,7 +29,7 @@ public function testMigrateToLatest()
2929
*/
3030
public function testUpgradeTo()
3131
{
32-
$tester = $this->executeCommand($this->getMigrateCommand(), array('to' => '201401011300'));
32+
$tester = $this->executeCommand('phpcr_migrations.command.migrate', array('to' => '201401011300'));
3333
$display = $tester->getDisplay();
3434

3535
$this->assertContains('Upgrading 1 version', $display);
@@ -43,8 +43,8 @@ public function testUpgradeTo()
4343
*/
4444
public function testUpgradeRevertTo()
4545
{
46-
$tester = $this->executeCommand($this->getMigrateCommand(), array());
47-
$tester = $this->executeCommand($this->getMigrateCommand(), array('to' => '201501011200'));
46+
$tester = $this->executeCommand('phpcr_migrations.command.migrate', array());
47+
$tester = $this->executeCommand('phpcr_migrations.command.migrate', array('to' => '201501011200'));
4848
$display = $tester->getDisplay();
4949

5050
$this->assertContains('Reverting 3 version', $display);

Tests/Functional/StatusCommandTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class StatusCommandTest extends BaseTestCase
1818
*/
1919
public function testShowAll()
2020
{
21-
$tester = $this->executeCommand($this->getStatusCommand(), array());
21+
$tester = $this->executeCommand('phpcr_migrations.command.status', array());
2222
$display = $tester->getDisplay();
2323

2424
$this->assertContains('No migrations have been executed', $display);
@@ -29,8 +29,8 @@ public function testShowAll()
2929
*/
3030
public function testShowCurrentVersion()
3131
{
32-
$tester = $this->executeCommand($this->getMigrateCommand(), array('to' => '201501011500'));
33-
$tester = $this->executeCommand($this->getStatusCommand(), array());
32+
$tester = $this->executeCommand('phpcr_migrations.command.migrate', array('to' => '201501011500'));
33+
$tester = $this->executeCommand('phpcr_migrations.command.status', array());
3434
$display = $tester->getDisplay();
3535

3636
$this->assertContains('201501011500', $display);

composer.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@
99
}
1010
],
1111
"require": {
12-
"phpcr/phpcr-migrations": "~0.1",
13-
"phpcr/phpcr-implementation": "~2.1",
14-
"doctrine/phpcr-bundle": "~1.0"
12+
"phpcr/phpcr-migrations": "^1.0",
13+
"phpcr/phpcr-implementation": "^2.1",
14+
"doctrine/phpcr-bundle": "^1.2"
1515
},
1616
"require-dev": {
17-
"symfony/symfony": "~2.4 || ~3.0",
18-
"symfony-cmf/testing": "~1.2"
17+
"symfony/symfony": "~2.3 || ~3.0",
18+
"symfony-cmf/testing": "~1.3"
1919
},
2020
"autoload": {
2121
"psr-4": {

0 commit comments

Comments
 (0)