Skip to content

Commit 8f3ffed

Browse files
Allow multipart aliases with drush sa, e.g. @location.site.env or @location.site, in addition to just @location or @site. (#3660)
1 parent 562e60e commit 8f3ffed

File tree

4 files changed

+22
-6
lines changed

4 files changed

+22
-6
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
"consolidation/config": "^1.1.0",
3333
"consolidation/output-formatters": "^3.1.12",
3434
"consolidation/robo": "^1.1.5",
35-
"consolidation/site-alias": "^1.1.1",
35+
"consolidation/site-alias": "^1.1.2",
3636
"grasmash/yaml-expander": "^1.1.1",
3737
"league/container": "~2",
3838
"psr/log": "~1.0",

scenarios/isolation-phpunit4/composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
"php": ">=5.6.0",
2828
"ext-dom": "*",
2929
"consolidation/config": "^1.1.0",
30-
"consolidation/site-alias": "^1.1.1",
30+
"consolidation/site-alias": "^1.1.2",
3131
"psr/log": "~1.0",
3232
"sebastian/version": "^1|^2",
3333
"symfony/finder": "~2.7|^3",

scenarios/isolation/composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
"php": ">=5.6.0",
2828
"ext-dom": "*",
2929
"consolidation/config": "^1.1.0",
30-
"consolidation/site-alias": "^1.1.1",
30+
"consolidation/site-alias": "^1.1.2",
3131
"psr/log": "~1.0",
3232
"sebastian/version": "^1|^2",
3333
"symfony/finder": "~2.7|^3",

src/Commands/core/SiteCommands.php

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -115,10 +115,11 @@ public function siteSet($site = '@none')
115115
*/
116116
public function siteAlias($site = null, $options = ['format' => 'yaml'])
117117
{
118-
// Check to see if the user provided a specification that matches
118+
// First check to see if the user provided a specification that matches
119119
// multiple sites.
120-
$aliasList = $this->siteAliasManager()->getMultiple($site);
121-
if (is_array($aliasList)) {
120+
list($locationPart, $sitePart) = $this->splitLocationFromSite($site);
121+
$aliasList = $this->siteAliasManager()->getMultiple($sitePart, $locationPart);
122+
if (is_array($aliasList) && !empty($aliasList)) {
122123
return new ListDataFromKeys($this->siteAliasExportList($aliasList, $options));
123124
}
124125

@@ -135,6 +136,21 @@ public function siteAlias($site = null, $options = ['format' => 'yaml'])
135136
}
136137
}
137138

139+
/**
140+
* splitLocationFromSite returns the location and the site if the
141+
* site alias is in the form '@location.site'. Otherwise it just
142+
* returns the site unchanged, without a location.
143+
*/
144+
protected function splitLocationFromSite($site)
145+
{
146+
$parts = explode('.', ltrim($site, '@'));
147+
148+
if (count($parts) == 2) {
149+
return [$parts[0], '@' . $parts[1]];
150+
}
151+
return [null, $site];
152+
}
153+
138154
/**
139155
* Convert legacy site alias files to the new yml format.
140156
*

0 commit comments

Comments
 (0)