Skip to content

Commit 6968f25

Browse files
authoredMar 9, 2023
Merge pull request #150 from totten/master-explicit-auto
Allow explicit-automatic flags
2 parents 343eaf5 + ffa554c commit 6968f25

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed
 

Diff for: ‎src/Bootstrap.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@
6161
* type of CMS is being used.
6262
* (Default: NULL)
6363
* - env: string|NULL. The environment variable which may contain the path to
64-
* civicrm.settings.php. Set NULL to disable.
64+
* civicrm.settings.php (or the token "Auto"). Set NULL to disable environment-checking.
6565
* (Default: CIVICRM_SETTINGS)
6666
* - httpHost: string|NULL. For multisite, the HTTP hostname.
6767
* - prefetch: bool. Whether to load various caches.
@@ -324,7 +324,7 @@ public function getCivicrmSettingsPhp($options) {
324324
if (defined('CIVICRM_CONFDIR') && file_exists(CIVICRM_CONFDIR . '/civicrm.settings.php')) {
325325
$settings = CIVICRM_CONFDIR . '/civicrm.settings.php';
326326
}
327-
elseif (!empty($options['env']) && getenv($options['env']) && file_exists(getenv($options['env']))) {
327+
elseif (!empty($options['env']) && getenv($options['env']) && getenv($options['env']) !== 'Auto' && file_exists(getenv($options['env']))) {
328328
$settings = getenv($options['env']);
329329
}
330330
elseif (!empty($options['settingsFile']) && file_exists($options['settingsFile'])) {

Diff for: ‎src/CmsBootstrap.php

+5-1
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,10 @@ public function bootCms() {
111111
'path' => '/' . parse_url($cmsExpr, PHP_URL_HOST) . parse_url($cmsExpr, PHP_URL_PATH),
112112
);
113113
$cms['path'] = preg_replace(';^//+;', '/', $cms['path']);
114+
if ($cms['type'] === 'Auto') {
115+
$isAutoPath = (trim($cms['path'], '/') === '.');
116+
$cms = $this->findCmsRoot($isAutoPath ? $this->getSearchDir() : $cms['path']);
117+
}
114118
if (!isset($this->options['user']) && parse_url($cmsExpr, PHP_URL_USER)) {
115119
$this->options['user'] = parse_url($cmsExpr, PHP_URL_USER);
116120
}
@@ -126,7 +130,7 @@ public function bootCms() {
126130
$cms = $this->findCmsRoot($this->getSearchDir());
127131
}
128132

129-
$this->writeln("CMS: " . json_encode($this->options, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES), OutputInterface::VERBOSITY_DEBUG);
133+
$this->writeln("CMS: " . json_encode($cms, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES), OutputInterface::VERBOSITY_DEBUG);
130134
if (empty($cms['path']) || empty($cms['type']) || !file_exists($cms['path'])) {
131135
$cmsJson = json_encode($cms, JSON_UNESCAPED_SLASHES);
132136
throw new \Exception("Failed to parse or find a CMS $cmsJson");

0 commit comments

Comments
 (0)
Failed to load comments.