class SiteSpecParser (View source)

Parse a string that contains a site specification.

Site specifications contain some of the following elements:

  • user
  • host
  • path
  • uri (multisite selector)

Properties

protected string $multisiteDirectoryRoot

Methods

array
parse(string $spec, string $root = '')

Parse a site specification

bool
validSiteSpec(string $spec)

Determine if the provided specification is valid. Note that this tests only for syntactic validity; to see if the specification is usable, call 'parse()', which will also filter out specifications for local sites that specify a multidev site that does not exist.

bool
isAliasName(string $aliasName)

Determine whether or not the provided name is an alias name.

setMultisiteDirectoryRoot($location)

No description

getMultisiteDirectoryRoot($root)

No description

array
patterns()

Return the set of regular expression patterns that match the available site specification formats.

array
match($spec)

Run through all of the available regex patterns and determine if any match the provided specification.

array
defaults($result = [])

Inflate the provided array so that it always contains the required elements.

array
mapResult(array $map, array $matches)

Take the data from the matches from the regular expression and plug them into the result array per the info in the provided map.

array
fixAndCheckUsability(array $result, $root)

Validate the provided result. If the result is local, then it must have a 'root'. If it does not, then fill in the root that was provided to us in our consturctor.

Details

array parse(string $spec, string $root = '')

Parse a site specification

Parameters

string $spec

A site specification in one of the accepted forms:

  • /path/to/drupal#uri
  • user@server/path/to/drupal#uri
  • user@server/path/to/drupal
  • user@server#uri or, a site name:
  • uri

string $root

Drupal root (if provided).

Return Value

array

A site specification array with the specified components filled in:

  • user
  • host
  • path
  • uri or, an empty array if the provided parameter is not a valid site spec.

bool validSiteSpec(string $spec)

Determine if the provided specification is valid. Note that this tests only for syntactic validity; to see if the specification is usable, call 'parse()', which will also filter out specifications for local sites that specify a multidev site that does not exist.

Parameters

string $spec parse()

Return Value

bool

bool isAliasName(string $aliasName)

Determine whether or not the provided name is an alias name.

Parameters

string $aliasName

Return Value

bool

setMultisiteDirectoryRoot($location)

No description

Parameters

$location

getMultisiteDirectoryRoot($root)

No description

Parameters

$root

protected array patterns()

Return the set of regular expression patterns that match the available site specification formats.

Return Value

array

key: site specification regex value: an array mapping from site specification component names to the elements in the 'matches' array containing the data for that element.

protected array match($spec)

Run through all of the available regex patterns and determine if any match the provided specification.

Parameters

$spec

Return Value

array parse()

protected array defaults($result = [])

Inflate the provided array so that it always contains the required elements.

Parameters

$result

Return Value

array parse()

protected array mapResult(array $map, array $matches)

Take the data from the matches from the regular expression and plug them into the result array per the info in the provided map.

Parameters

array $map

An array mapping from result key to matches index.

array $matches

The matched strings returned from preg_match

Return Value

array parse()

protected array fixAndCheckUsability(array $result, $root)

Validate the provided result. If the result is local, then it must have a 'root'. If it does not, then fill in the root that was provided to us in our consturctor.

Parameters

array $result

parse() result.

$root

Return Value

array parse()