1 | <?php |
||
13 | class SiteSpecParser |
||
14 | { |
||
15 | /** |
||
16 | * @var string Relative path from the site root to directory where |
||
17 | * multisite configuration directories are found. |
||
18 | */ |
||
19 | protected $multisiteDirectoryRoot = 'sites'; |
||
20 | |||
21 | /** |
||
22 | * Parse a site specification |
||
23 | * |
||
24 | * @param string $spec |
||
25 | * A site specification in one of the accepted forms: |
||
26 | * - /path/to/drupal#uri |
||
27 | * - user@server/path/to/drupal#uri |
||
28 | * - user@server/path/to/drupal |
||
29 | * - user@server#uri |
||
30 | * or, a site name: |
||
31 | * - #uri |
||
32 | * @param string $root |
||
33 | * Drupal root (if provided). |
||
34 | * @return array |
||
35 | * A site specification array with the specified components filled in: |
||
36 | * - user |
||
37 | * - host |
||
38 | * - path |
||
39 | * - uri |
||
40 | * or, an empty array if the provided parameter is not a valid site spec. |
||
41 | */ |
||
42 | public function parse($spec, $root = '') |
||
47 | |||
48 | /** |
||
49 | * Determine if the provided specification is valid. Note that this |
||
50 | * tests only for syntactic validity; to see if the specification is |
||
51 | * usable, call 'parse()', which will also filter out specifications |
||
52 | * for local sites that specify a multidev site that does not exist. |
||
53 | * |
||
54 | * @param string $spec |
||
55 | * @see parse() |
||
56 | * @return bool |
||
57 | */ |
||
58 | public function validSiteSpec($spec) |
||
63 | |||
64 | /** |
||
65 | * Determine whether or not the provided name is an alias name. |
||
66 | * |
||
67 | * @param string $aliasName |
||
68 | * @return bool |
||
69 | */ |
||
70 | public function isAliasName($aliasName) |
||
74 | |||
75 | public function setMultisiteDirectoryRoot($location) |
||
79 | |||
80 | public function getMultisiteDirectoryRoot($root) |
||
84 | |||
85 | /** |
||
86 | * Return the set of regular expression patterns that match the available |
||
87 | * site specification formats. |
||
88 | * |
||
89 | * @return array |
||
90 | * key: site specification regex |
||
91 | * value: an array mapping from site specification component names to |
||
92 | * the elements in the 'matches' array containing the data for that element. |
||
93 | */ |
||
94 | protected function patterns() |
||
133 | |||
134 | /** |
||
135 | * Run through all of the available regex patterns and determine if |
||
136 | * any match the provided specification. |
||
137 | * |
||
138 | * @return array |
||
139 | * @see parse() |
||
140 | */ |
||
141 | protected function match($spec) |
||
150 | |||
151 | /** |
||
152 | * Inflate the provided array so that it always contains the required |
||
153 | * elements. |
||
154 | * |
||
155 | * @return array |
||
156 | * @see parse() |
||
157 | */ |
||
158 | protected function defaults($result = []) |
||
167 | |||
168 | /** |
||
169 | * Take the data from the matches from the regular expression and |
||
170 | * plug them into the result array per the info in the provided map. |
||
171 | * |
||
172 | * @param array $map |
||
173 | * An array mapping from result key to matches index. |
||
174 | * @param array $matches |
||
175 | * The matched strings returned from preg_match |
||
176 | * @return array |
||
177 | * @see parse() |
||
178 | */ |
||
179 | protected function mapResult($map, $matches) |
||
194 | |||
195 | /** |
||
196 | * Validate the provided result. If the result is local, then it must |
||
197 | * have a 'root'. If it does not, then fill in the root that was provided |
||
198 | * to us in our consturctor. |
||
199 | * |
||
200 | * @param array $result |
||
201 | * @see parse() result. |
||
202 | * @return array |
||
203 | * @see parse() |
||
204 | */ |
||
205 | protected function fixAndCheckUsability($result, $root) |
||
234 | } |
||
235 |