SiteAliasFileLoader
class SiteAliasFileLoader (View source)
Discover alias files:
- sitename.site.yml: contains multiple aliases, one for each of the environments of 'sitename'.
Properties
protected SiteAliasFileDiscovery | $discovery | ||
protected array | $referenceData | ||
protected array | $loader | ||
protected string | $root |
Methods
Allow configuration data to be used in replacements in the alias file.
Allow 'self.site.yml' to be applied to any alias record found.
Add a search location to our discovery object.
Return our discovery object.
Given only a site name, load the default environment from it.
Return a list of all available alias files. Does not include legacy files.
Given an alias name that might represent multiple sites,
return a list of all matching alias records. If nothing was found,
or the name represents a single site + env, then we take
no action and return false
.
Given a location, return all alias files located there.
No description
isValidEnvName determines if a given entry should be skipped or not (e.g. the "common" entry).
If the alias name is '@sitename', or if it is '@sitename.env', then look for a sitename.site.yml file that contains it. We also handle '@location.sitename.env' here as well.
Given only the path to an alias file site.alias.yml
, return all
of the alias records for every environment stored in that file.
Given the path to a single site alias file site.alias.yml
,
return the site
part.
Chop off the aliases.yml
or alias.yml
part of a path. This works
just like basename
, except it will throw if the provided path
does not end in the specified extension.
Given an alias name and a path, load the data from the path and process it as needed to generate the alias record.
Load the yml from the given path
Given an array of site aliases, find the first one that is local (has no 'host' item) and also contains a 'self.site.yml' file.
Check to see if there is a 'drush/sites/self.site.yml' file at the provided root, or one directory up from there.
Load the contents of the specified file.
No description
Given an array containing site alias data, return an alias record containing the data for the requested record. If there is a 'common' section, then merge that in as well.
getRequestedEnvData fetches the data for the specified environment from the provided site record data.
Determine whether there is a valid-looking environment '$env' in the provided site alias data.
Adjust the alias data for a single-site alias. Usually, a .yml alias file will contain multiple entries, one for each of the environments of an alias. If there are no environments
A single-environment alias looks something like this:
Return the name of the environment requested.
Given a data array containing site alias environments, determine which envirionmnet should be used as the default environment.
Details
__construct(SiteAliasFileDiscovery|null $discovery = null)
SiteAliasFileLoader constructor
setReferenceData($data)
Allow configuration data to be used in replacements in the alias file.
setRoot($root)
Allow 'self.site.yml' to be applied to any alias record found.
$this
addSearchLocation(string $path)
Add a search location to our discovery object.
SiteAliasFileDiscovery
discovery()
Return our discovery object.
SiteAlias|false
load(SiteAliasName $aliasName)
Load the file containing the specified alias name.
protected
loadDefaultEnvFromSitename($sitename)
Given only a site name, load the default environment from it.
SiteAlias[]
loadAll()
Return a list of all site aliases loadable from any findable path.
string[]
listAll(string $location = '')
Return a list of all available alias files. Does not include legacy files.
SiteAlias[]|false
loadMultiple(string $sitename, $location = null)
Given an alias name that might represent multiple sites,
return a list of all matching alias records. If nothing was found,
or the name represents a single site + env, then we take
no action and return false
.
SiteAlias[]
loadLocation(string $location)
Given a location, return all alias files located there.
protected SiteAlias[]
createSiteAliassFromSiteData($sitename, array $siteData, $location = '')
No description
protected
isValidEnvName(string $envName)
isValidEnvName determines if a given entry should be skipped or not (e.g. the "common" entry).
protected
storeSiteAliasInResut($result, SiteAlias $aliasRecord)
No description
protected SiteAlias|false
loadSingleAliasFile(SiteAliasName $aliasName)
If the alias name is '@sitename', or if it is '@sitename.env', then look for a sitename.site.yml file that contains it. We also handle '@location.sitename.env' here as well.
protected SiteAlias[]
loadSingleSiteAliasFileAtPath(string $path)
Given only the path to an alias file site.alias.yml
, return all
of the alias records for every environment stored in that file.
protected
siteNameFromPath(string $path)
Given the path to a single site alias file site.alias.yml
,
return the site
part.
protected string
basenameWithoutExtension(string $path, string $extension)
Chop off the aliases.yml
or alias.yml
part of a path. This works
just like basename
, except it will throw if the provided path
does not end in the specified extension.
protected SiteAlias|false
loadSingleAliasFileWithNameAtPath(SiteAliasName $aliasName, string $path)
Given an alias name and a path, load the data from the path and process it as needed to generate the alias record.
protected array|bool
loadSiteDataFromPath(string $path)
Load the yml from the given path
protected array
findSelfSiteAliases($site_aliases, $path)
Given an array of site aliases, find the first one that is local (has no 'host' item) and also contains a 'self.site.yml' file.
protected
loadSelfSiteData($root)
Check to see if there is a 'drush/sites/self.site.yml' file at the provided root, or one directory up from there.
protected array
loadData(string $path)
Load the contents of the specified file.
DataFileLoaderInterface
getLoader($extension)
No description
addLoader($extension, DataFileLoaderInterface $loader)
No description
protected SiteAlias|false
fetchSiteAliasFromSiteAliasData(SiteAliasName $aliasName, ConfigProcessor $processor, array $data)
Given an array containing site alias data, return an alias record containing the data for the requested record. If there is a 'common' section, then merge that in as well.
protected array|false
getRequestedEnvData(array $data, string $env)
getRequestedEnvData fetches the data for the specified environment from the provided site record data.
protected bool
siteEnvExists(array $data, string $env)
Determine whether there is a valid-looking environment '$env' in the provided site alias data.
protected array
adjustIfSingleAlias(array $data)
Adjust the alias data for a single-site alias. Usually, a .yml alias file will contain multiple entries, one for each of the environments of an alias. If there are no environments
protected bool
detectSingleAlias(array $data)
A single-environment alias looks something like this:
root: /path/to/drupal uri: https://mysite.org
A multiple-environment alias looks something like this:
default: dev dev: root: /path/to/dev uri: https://dev.mysite.org stage: root: /path/to/stage uri: https://stage.mysite.org
The differentiator between these two is that the multi-environment alias always has top-level elements that are associative arrays, and the single-environment alias never does.
protected string
getEnvironmentName(SiteAliasName $aliasName, array $data)
Return the name of the environment requested.
protected string
getDefaultEnvironmentName(array $data)
Given a data array containing site alias environments, determine which envirionmnet should be used as the default environment.