Skip to content

Commit 244d845

Browse files
authored
Move migrations to core bundle (see contao#2545)
Description ----------- | Q | A | -----------------| --- | Fixed issues | Fixes contao#2364 Commits ------- 1d6f417 Move migrations to core bundle 20dfde3 Fix missing globals array 51fb5c7 PHPStan 5034731 Pass the filesystem as dependency and remove the Contao 3 migrations
1 parent 8605bc4 commit 244d845

File tree

15 files changed

+71
-266
lines changed

15 files changed

+71
-266
lines changed

installation-bundle/src/Database/Version400Update.php renamed to core-bundle/src/Migration/Version400/Version400Update.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
* @license LGPL-3.0-or-later
1111
*/
1212

13-
namespace Contao\InstallationBundle\Database;
13+
namespace Contao\CoreBundle\Migration\Version400;
1414

1515
use Contao\CoreBundle\Migration\AbstractMigration;
1616
use Contao\CoreBundle\Migration\MigrationResult;

installation-bundle/src/Database/Version410Update.php renamed to core-bundle/src/Migration/Version401/Version410Update.php

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,9 @@
1010
* @license LGPL-3.0-or-later
1111
*/
1212

13-
namespace Contao\InstallationBundle\Database;
13+
namespace Contao\CoreBundle\Migration\Version401;
1414

15+
use Contao\CoreBundle\Framework\ContaoFramework;
1516
use Contao\CoreBundle\Migration\AbstractMigration;
1617
use Contao\CoreBundle\Migration\MigrationResult;
1718
use Doctrine\DBAL\Connection;
@@ -26,9 +27,15 @@ class Version410Update extends AbstractMigration
2627
*/
2728
private $connection;
2829

29-
public function __construct(Connection $connection)
30+
/**
31+
* @var ContaoFramework
32+
*/
33+
private $framework;
34+
35+
public function __construct(Connection $connection, ContaoFramework $framework)
3036
{
3137
$this->connection = $connection;
38+
$this->framework = $framework;
3239
}
3340

3441
public function getName(): string
@@ -51,6 +58,8 @@ public function shouldRun(): bool
5158

5259
public function run(): MigrationResult
5360
{
61+
$this->framework->initialize();
62+
5463
$crop = $GLOBALS['TL_CROP'];
5564

5665
if (empty($crop)) {

installation-bundle/src/Database/Version430Update.php renamed to core-bundle/src/Migration/Version403/Version430Update.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
* @license LGPL-3.0-or-later
1111
*/
1212

13-
namespace Contao\InstallationBundle\Database;
13+
namespace Contao\CoreBundle\Migration\Version403;
1414

1515
use Contao\CoreBundle\Migration\AbstractMigration;
1616
use Contao\CoreBundle\Migration\MigrationResult;

installation-bundle/src/Database/Version440Update.php renamed to core-bundle/src/Migration/Version404/Version440Update.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
* @license LGPL-3.0-or-later
1111
*/
1212

13-
namespace Contao\InstallationBundle\Database;
13+
namespace Contao\CoreBundle\Migration\Version404;
1414

1515
use Contao\CoreBundle\Migration\AbstractMigration;
1616
use Contao\CoreBundle\Migration\MigrationResult;

installation-bundle/src/Database/Version447Update.php renamed to core-bundle/src/Migration/Version404/Version447Update.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
* @license LGPL-3.0-or-later
1111
*/
1212

13-
namespace Contao\InstallationBundle\Database;
13+
namespace Contao\CoreBundle\Migration\Version404;
1414

1515
use Contao\CoreBundle\Migration\AbstractMigration;
1616
use Contao\CoreBundle\Migration\MigrationResult;

installation-bundle/src/Database/Version450Update.php renamed to core-bundle/src/Migration/Version405/Version450Update.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
* @license LGPL-3.0-or-later
1111
*/
1212

13-
namespace Contao\InstallationBundle\Database;
13+
namespace Contao\CoreBundle\Migration\Version405;
1414

1515
use Contao\CoreBundle\Migration\AbstractMigration;
1616
use Contao\CoreBundle\Migration\MigrationResult;

installation-bundle/src/Database/Version460Update.php renamed to core-bundle/src/Migration/Version406/Version460Update.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
* @license LGPL-3.0-or-later
1111
*/
1212

13-
namespace Contao\InstallationBundle\Database;
13+
namespace Contao\CoreBundle\Migration\Version406;
1414

1515
use Contao\CoreBundle\Migration\AbstractMigration;
1616
use Contao\CoreBundle\Migration\MigrationResult;

installation-bundle/src/Database/Version470Update.php renamed to core-bundle/src/Migration/Version407/Version470Update.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
* @license LGPL-3.0-or-later
1111
*/
1212

13-
namespace Contao\InstallationBundle\Database;
13+
namespace Contao\CoreBundle\Migration\Version407;
1414

1515
use Contao\CoreBundle\Migration\AbstractMigration;
1616
use Contao\CoreBundle\Migration\MigrationResult;

installation-bundle/src/Database/Version480Update.php renamed to core-bundle/src/Migration/Version408/Version480Update.php

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,14 @@
1010
* @license LGPL-3.0-or-later
1111
*/
1212

13-
namespace Contao\InstallationBundle\Database;
13+
namespace Contao\CoreBundle\Migration\Version408;
1414

1515
use Contao\CoreBundle\Migration\AbstractMigration;
1616
use Contao\CoreBundle\Migration\MigrationResult;
1717
use Contao\File;
1818
use Contao\StringUtil;
1919
use Doctrine\DBAL\Connection;
20+
use Symfony\Component\Filesystem\Filesystem;
2021

2122
/**
2223
* @internal
@@ -28,14 +29,20 @@ class Version480Update extends AbstractMigration
2829
*/
2930
private $connection;
3031

32+
/**
33+
* @var Filesystem
34+
*/
35+
private $filesystem;
36+
3137
/**
3238
* @var string
3339
*/
3440
private $projectDir;
3541

36-
public function __construct(Connection $connection, string $projectDir)
42+
public function __construct(Connection $connection, Filesystem $filesystem, string $projectDir)
3743
{
3844
$this->connection = $connection;
45+
$this->filesystem = $filesystem;
3946
$this->projectDir = $projectDir;
4047
}
4148

@@ -153,7 +160,7 @@ public function run(): MigrationResult
153160

154161
// Convert the important part to relative values as fractions
155162
while (false !== ($file = $statement->fetch(\PDO::FETCH_OBJ))) {
156-
if (!file_exists($this->projectDir.'/'.$file->path) || is_dir($this->projectDir.'/'.$file->path)) {
163+
if (!$this->filesystem->exists($this->projectDir.'/'.$file->path) || is_dir($this->projectDir.'/'.$file->path)) {
157164
continue;
158165
}
159166

core-bundle/src/Resources/config/migrations.yml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,49 @@ services:
44

55
Contao\CoreBundle\Migration\MigrationCollection: ~
66

7+
Contao\CoreBundle\Migration\Version400\Version400Update:
8+
arguments:
9+
- '@database_connection'
10+
11+
Contao\CoreBundle\Migration\Version401\Version410Update:
12+
arguments:
13+
- '@database_connection'
14+
- '@contao.framework'
15+
16+
Contao\CoreBundle\Migration\Version403\Version430Update:
17+
arguments:
18+
- '@database_connection'
19+
20+
Contao\CoreBundle\Migration\Version404\Version440Update:
21+
arguments:
22+
- '@database_connection'
23+
24+
Contao\CoreBundle\Migration\Version404\Version447Update:
25+
arguments:
26+
- '@database_connection'
27+
- '@translator'
28+
29+
Contao\CoreBundle\Migration\Version405\Version450Update:
30+
arguments:
31+
- '@database_connection'
32+
33+
Contao\CoreBundle\Migration\Version406\Version460Update:
34+
arguments:
35+
- '@database_connection'
36+
37+
Contao\CoreBundle\Migration\Version407\Version470Update:
38+
arguments:
39+
- '@database_connection'
40+
- '@filesystem'
41+
- '%contao.upload_path%'
42+
- '%kernel.project_dir%'
43+
44+
Contao\CoreBundle\Migration\Version408\Version480Update:
45+
arguments:
46+
- '@database_connection'
47+
- '@filesystem'
48+
- '%kernel.project_dir%'
49+
750
Contao\CoreBundle\Migration\Version409\CeAccessMigration:
851
arguments:
952
- '@database_connection'

0 commit comments

Comments
 (0)