Skip to content

Commit 2496176

Browse files
authored
Merge pull request #35 from pagemachine/typo3v12-base-path
Support extensions in Composer vendor-dir
2 parents fd85626 + c3d1e46 commit 2496176

File tree

1 file changed

+21
-5
lines changed

1 file changed

+21
-5
lines changed

Classes/Configuration/PhinxConfiguration.php

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,18 @@ final class PhinxConfiguration
1111

1212
public function toArray(): array
1313
{
14-
$extensionsPath = Environment::getExtensionsPath();
14+
$basePath = $this->getBasePath();
1515
$connectionParameters = $this->getConnectionParameters();
1616

1717
return [
1818
'paths' => [
1919
'migrations' => sprintf(
20-
'%s/*/{Migrations,Classes/Migrations}/Phinx',
21-
$extensionsPath
20+
'%s/{Migrations,Classes/Migrations}/Phinx',
21+
$basePath
2222
),
2323
'seeds' => sprintf(
24-
'%s/*/{Migrations,Classes/Migrations}/Phinx/Seeds',
25-
$extensionsPath
24+
'%s/{Migrations,Classes/Migrations}/Phinx/Seeds',
25+
$basePath
2626
),
2727
],
2828
'environments' => [
@@ -42,6 +42,22 @@ public function toArray(): array
4242
];
4343
}
4444

45+
private function getBasePath(): string
46+
{
47+
if ($this->isLocatedInExtensionsPath()) {
48+
// <web-dir>/typo3conf/ext/*
49+
return sprintf('%s/*', Environment::getExtensionsPath());
50+
}
51+
52+
// <vendor-dir>/*/*
53+
return sprintf('%s/*/*', dirname(__DIR__, 4));
54+
}
55+
56+
private function isLocatedInExtensionsPath(): bool
57+
{
58+
return dirname(__DIR__, 3) === Environment::getExtensionsPath();
59+
}
60+
4561
private function getConnectionParameters(): array
4662
{
4763
return $GLOBALS['TYPO3_CONF_VARS']['DB']['Connections']['Default'];

0 commit comments

Comments
 (0)