Updated Drupal to 8.6. This goes with the following updates because it's possible...
[yaffs-website] / vendor / consolidation / site-alias / src / SiteAliasManager.php
similarity index 86%
rename from vendor/drush/drush/src/SiteAlias/SiteAliasManager.php
rename to vendor/consolidation/site-alias/src/SiteAliasManager.php
index 39320056cd32f9e0ba0514e40c3d1af484bf2b2c..2efce6bbc70954053f60ea4a6fbf03d5dec5106c 100644 (file)
@@ -1,5 +1,5 @@
 <?php
-namespace Drush\SiteAlias;
+namespace Consolidation\SiteAlias;
 
 /**
  * Site Alias manager
@@ -7,7 +7,6 @@ namespace Drush\SiteAlias;
 class SiteAliasManager
 {
     protected $aliasLoader;
-    protected $legacyAliasConverter;
     protected $selfAliasRecord;
     protected $specParser;
     protected $root = '';
@@ -20,7 +19,6 @@ class SiteAliasManager
     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;
@@ -32,6 +30,7 @@ class SiteAliasManager
     public function setReferenceData($data)
     {
         $this->aliasLoader->setReferenceData($data);
+        return $this;
     }
 
     /**
@@ -162,10 +161,10 @@ class SiteAliasManager
      * 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();
@@ -175,11 +174,23 @@ class SiteAliasManager
             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],
@@ -196,8 +207,8 @@ class SiteAliasManager
      *
      * @return string[]
      */
-    public function listAllFilePaths()
+    public function listAllFilePaths($location = '')
     {
-        return $this->aliasLoader->listAll();
+        return $this->aliasLoader->listAll($location);
     }
 }