<?php
-namespace Drush\SiteAlias;
+namespace Consolidation\SiteAlias;
/**
* Site Alias manager
class SiteAliasManager
{
protected $aliasLoader;
- protected $legacyAliasConverter;
protected $selfAliasRecord;
protected $specParser;
protected $root = '';
public function __construct($aliasLoader = null, $root = '')
{
$this->aliasLoader = $aliasLoader ?: new SiteAliasFileLoader();
- $this->legacyAliasConverter = new LegacyAliasConverter($this->aliasLoader->discovery());
$this->specParser = new SiteSpecParser();
$this->selfAliasRecord = new AliasRecord();
$this->root = $root;
public function setReferenceData($data)
{
$this->aliasLoader->setReferenceData($data);
+ return $this;
}
/**
* If the provided name is a site specification et. al.,
* then this method will return 'false'.
*
- * @param string $name Alias name or site specification
+ * @param string $name Alias name
* @return AliasRecord[]|false
*/
- public function getMultiple($name)
+ public function getMultiple($name = '')
{
if (empty($name)) {
return $this->aliasLoader->loadAll();
return false;
}
- // Trim off the '@' and load all that match
- $result = $this->aliasLoader->loadMultiple(ltrim($name, '@'));
+ // Trim off the '@'
+ $trimmedName = ltrim($name, '@');
+
+ // If the provided name is a location, return all aliases there
+ $result = $this->aliasLoader->loadLocation($trimmedName);
+ if (!empty($result)) {
+ return $result;
+ }
+
+ // If the provided name is a site, return all environments
+ $result = $this->aliasLoader->loadMultiple($trimmedName);
+ if (!empty($result)) {
+ return $result;
+ }
// Special checking for @self
- if ($name == '@self') {
+ if ($trimmedName == 'self') {
$self = $this->getSelf();
$result = array_merge(
['@self' => $self],
*
* @return string[]
*/
- public function listAllFilePaths()
+ public function listAllFilePaths($location = '')
{
- return $this->aliasLoader->listAll();
+ return $this->aliasLoader->listAll($location);
}
}