Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 25 additions & 10 deletions src/ApplicationLinker.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use DirectoryIterator;
use RecursiveDirectoryIterator;
use RecursiveIteratorIterator;
use ReflectionMethod;

class ApplicationLinker
{
Expand Down Expand Up @@ -176,16 +177,30 @@ public function run(): void
continue;
}
$this->filesystem->ensureDirectoryExists($appWebDir . DIRECTORY_SEPARATOR . $relativePath);
$pathProxyToAutoloader = $this->filesystem->findShortestPath(
$appWebDir . DIRECTORY_SEPARATOR . $relativePathName,
$vendorDir . DIRECTORY_SEPARATOR . 'autoload.php',
preferRelative: true
);
$pathProxyToFile = $this->filesystem->findShortestPath(
$appWebDir . DIRECTORY_SEPARATOR . $relativePathName,
$appVendorDir . DIRECTORY_SEPARATOR . $relativePathName,
preferRelative: true
);
$reflection = new ReflectionMethod($this->filesystem, 'findShortestPath');
if ($reflection->getNumberOfParameters() >= 4) {
$pathProxyToAutoloader = $this->filesystem->findShortestPath(
$appWebDir . DIRECTORY_SEPARATOR . $relativePathName,
$vendorDir . DIRECTORY_SEPARATOR . 'autoload.php',
preferRelative: true
);
$pathProxyToFile = $this->filesystem->findShortestPath(
$appWebDir . DIRECTORY_SEPARATOR . $relativePathName,
$appVendorDir . DIRECTORY_SEPARATOR . $relativePathName,
preferRelative: true
);
} else {
// Older composer versions don't support preferRelative
$pathProxyToAutoloader = $this->filesystem->findShortestPath(
$appWebDir . DIRECTORY_SEPARATOR . $relativePathName,
$vendorDir . DIRECTORY_SEPARATOR . 'autoload.php',
);
$pathProxyToFile = $this->filesystem->findShortestPath(
$appWebDir . DIRECTORY_SEPARATOR . $relativePathName,
$appVendorDir . DIRECTORY_SEPARATOR . $relativePathName,
);
}


$originalContent = file_get_contents($appVendorDir . DIRECTORY_SEPARATOR . $relativePathName);
if (str_contains((string) $originalContent, '<?php')) {
Expand Down
10 changes: 9 additions & 1 deletion src/HordeLocalFileWriter.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ private function processApp(string $app): void
$hordeBaseDir = $this->vendorHordeDir;
}
$hordeLocalFileContent = sprintf(
"<?php if (!defined('HORDE_BASE')) define('HORDE_BASE', '%s');\nif (!defined('HORDE_CONFIG_BASE')) define('HORDE_CONFIG_BASE', '%s');\n",
"<?php\nif (!defined('HORDE_BASE')) define('HORDE_BASE', '%s');\nif (!defined('HORDE_CONFIG_BASE')) define('HORDE_CONFIG_BASE', '%s');\n",
$hordeBaseDir,
$this->configDir
);
Expand All @@ -65,6 +65,14 @@ private function processApp(string $app): void
$hordeLocalFileContent .= $this->_legacyWorkaround($this->filesystem->normalizePath($this->vendorDir));
$hordeLocalFileContent .= "require_once('" . $this->vendorDir . "/autoload.php');";
}
$appNameUpper = strtoupper($name);
$hordeLocalFileContent .= sprintf(
"\nif (!defined('%s_TEMPLATES')) define('%s_TEMPLATES', '%s');\n",
$appNameUpper,
$appNameUpper,
$this->vendorDir . DIRECTORY_SEPARATOR . $vendor . DIRECTORY_SEPARATOR . $name . DIRECTORY_SEPARATOR . 'templates',
);

$autoloadExtraFilePath = $this->baseDir . '/var/config/autoload-extra.php';
if (file_exists($autoloadExtraFilePath)) {
$hordeLocalFileContent .= "\nrequire_once('$autoloadExtraFilePath')\n";
Expand Down
5 changes: 3 additions & 2 deletions src/RegistrySnippetFileWriter.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,12 @@ public function run(): void
' * - var/config/horde/registry-sub.domain.org.php' . PHP_EOL .
' */' . PHP_EOL;

$appInVendorDir = $this->baseDir . DIRECTORY_SEPARATOR . 'vendor' . DIRECTORY_SEPARATOR . $appVendor . DIRECTORY_SEPARATOR . $appName . DIRECTORY_SEPARATOR;
if ($app == 'horde/horde') {
$registryAppFilename = $this->configRegistryDir . '/01-location-' . $appName . '.php';
$registryAppSnippet .=
'$this->applications[\'horde\'][\'fileroot\'] = $app_fileroot;' . PHP_EOL .
'$this->applications[\'' . $appName . '\'][\'fileroot\'] = \'' . $appInVendorDir . '\';' . PHP_EOL .
'$this->applications[\'' . $appName . '\'][\'templates\'] = \'' . $appInVendorDir . 'templates' . DIRECTORY_SEPARATOR . '\';' . PHP_EOL .
'$this->applications[\'horde\'][\'webroot\'] = $app_webroot;' . PHP_EOL .
'$this->applications[\'horde\'][\'jsfs\'] = $deployment_fileroot . \'/js/horde/\';' . PHP_EOL .
'$this->applications[\'horde\'][\'jsuri\'] = $deployment_webroot . \'js/horde/\';' . PHP_EOL .
Expand All @@ -98,7 +100,6 @@ public function run(): void
} else {
// A registry snippet should ensure the install dir is known
$registryAppFilename = $this->configRegistryDir . '/02-location-' . $appName . '.php';
$appInVendorDir = $this->baseDir . DIRECTORY_SEPARATOR . 'vendor' . DIRECTORY_SEPARATOR . $appVendor . DIRECTORY_SEPARATOR . $appName . DIRECTORY_SEPARATOR;
$registryAppSnippet .=
'$this->applications[\'' . $appName . '\'][\'fileroot\'] = \'' . $appInVendorDir . '\';' . PHP_EOL .
'$this->applications[\'' . $appName . '\'][\'templates\'] = \'' . $appInVendorDir . 'templates' . DIRECTORY_SEPARATOR . '\';' . PHP_EOL .
Expand Down
Loading