Skip to content

Commit 985c998

Browse files
authored
Merge pull request #86 from pagemachine/toplevel-paths
Support toplevel paths
2 parents 9cc9249 + 67ebea6 commit 985c998

File tree

2 files changed

+35
-14
lines changed

2 files changed

+35
-14
lines changed

Classes/Configuration/PhinxConfiguration.php

Lines changed: 33 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -12,20 +12,10 @@ final class PhinxConfiguration
1212

1313
public function toArray(): array
1414
{
15-
$basePath = $this->getBasePath();
1615
$connectionParameters = $this->getConnectionParameters();
1716

1817
return [
19-
'paths' => [
20-
'migrations' => sprintf(
21-
'%s/{Migrations,Classes/Migrations}/Phinx',
22-
$basePath
23-
),
24-
'seeds' => sprintf(
25-
'%s/{Migrations,Classes/Migrations}/Phinx/Seeds',
26-
$basePath
27-
),
28-
],
18+
'paths' => $this->getPaths(),
2919
'environments' => [
3020
'default_migration_table' => self::MIGRATION_TABLE_NAME,
3121
'default_environment' => 'typo3',
@@ -43,22 +33,51 @@ public function toArray(): array
4333
];
4434
}
4535

46-
private function getBasePath(): string
36+
private function getPaths(): array
4737
{
4838
if ($this->isLocatedInExtensionsPath()) {
4939
// <web-dir>/typo3conf/ext/*
50-
return sprintf('%s/*', Environment::getExtensionsPath());
40+
return [
41+
'migrations' => sprintf(
42+
'%s/*/{Migrations,Classes/Migrations}/Phinx',
43+
Environment::getExtensionsPath(),
44+
),
45+
'seeds' => sprintf(
46+
'%s/*/{Migrations,Classes/Migrations}/Phinx/Seeds',
47+
Environment::getExtensionsPath(),
48+
),
49+
];
5150
}
5251

5352
// <vendor-dir>/*/*
54-
return sprintf('%s/*/*', dirname(__DIR__, 4));
53+
return [
54+
'migrations' => [
55+
sprintf('%s/migrations/phinx', Environment::getProjectPath()),
56+
sprintf(
57+
'%s/*/*/{Migrations,Classes/Migrations}/Phinx',
58+
$this->getVendorPath(),
59+
),
60+
],
61+
'seeds' => [
62+
sprintf('%s/migrations/phinx/seeds', Environment::getProjectPath()),
63+
sprintf(
64+
'%s/*/*/{Migrations,Classes/Migrations}/Phinx/Seeds',
65+
$this->getVendorPath(),
66+
),
67+
],
68+
];
5569
}
5670

5771
private function isLocatedInExtensionsPath(): bool
5872
{
5973
return dirname(__DIR__, 3) === Environment::getExtensionsPath();
6074
}
6175

76+
private function getVendorPath(): string
77+
{
78+
return dirname(__DIR__, 4);
79+
}
80+
6281
private function getConnectionParameters(): array
6382
{
6483
return $GLOBALS['TYPO3_CONF_VARS']['DB']['Connections']['Default'];

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ Notice that these wrapper commands are executed by TYPO3, thus the full API like
3030

3131
The following paths are used for migrations:
3232

33+
* `migrations/phinx` (Composer Mode)
3334
* `vendor/*/*/Migrations/Phinx`
3435
* `vendor/*/*/Classes/Migrations/Phinx`
3536

@@ -47,6 +48,7 @@ the desired location.
4748

4849
The following paths are used for seeds:
4950

51+
* `migrations/phinx/seeds` (Composer Mode)
5052
* `vendor/*/*/Migrations/Phinx/Seeds`
5153
* `vendor/*/*/Classes/Migrations/Phinx/Seeds`
5254

0 commit comments

Comments
 (0)