1 | <?php |
||
13 | class SiteSpecParser |
||
14 | { |
||
15 | /** |
||
16 | * Parse a site specification |
||
17 | * |
||
18 | * @param string $spec |
||
19 | * A site specification in one of the accepted forms: |
||
20 | * - /path/to/drupal#uri |
||
21 | * - user@server/path/to/drupal#uri |
||
22 | * - user@server/path/to/drupal |
||
23 | * - user@server#uri |
||
24 | * or, a site name: |
||
25 | * - #uri |
||
26 | * @param string $root |
||
27 | * Drupal root (if provided). |
||
28 | * @return array |
||
29 | * A site specification array with the specified components filled in: |
||
30 | * - user |
||
31 | * - host |
||
32 | * - path |
||
33 | * - uri |
||
34 | * or, an empty array if the provided parameter is not a valid site spec. |
||
35 | */ |
||
36 | public function parse($spec, $root = '') |
||
41 | |||
42 | /** |
||
43 | * Determine if the provided specification is valid. Note that this |
||
44 | * tests only for syntactic validity; to see if the specification is |
||
45 | * usable, call 'parse()', which will also filter out specifications |
||
46 | * for local sites that specify a multidev site that does not exist. |
||
47 | * |
||
48 | * @param string $spec |
||
49 | * @see parse() |
||
50 | * @return bool |
||
51 | */ |
||
52 | public function validSiteSpec($spec) |
||
57 | |||
58 | /** |
||
59 | * Determine whether or not the provided name is an alias name. |
||
60 | * |
||
61 | * @param string $aliasName |
||
62 | * @return bool |
||
63 | */ |
||
64 | public function isAliasName($aliasName) |
||
68 | |||
69 | /** |
||
70 | * Return the set of regular expression patterns that match the available |
||
71 | * site specification formats. |
||
72 | * |
||
73 | * @return array |
||
74 | * key: site specification regex |
||
75 | * value: an array mapping from site specification component names to |
||
76 | * the elements in the 'matches' array containing the data for that element. |
||
77 | */ |
||
78 | protected function patterns() |
||
117 | |||
118 | /** |
||
119 | * Run through all of the available regex patterns and determine if |
||
120 | * any match the provided specification. |
||
121 | * |
||
122 | * @return array |
||
123 | * @see parse() |
||
124 | */ |
||
125 | protected function match($spec) |
||
134 | |||
135 | /** |
||
136 | * Inflate the provided array so that it always contains the required |
||
137 | * elements. |
||
138 | * |
||
139 | * @return array |
||
140 | * @see parse() |
||
141 | */ |
||
142 | protected function defaults($result = []) |
||
151 | |||
152 | /** |
||
153 | * Take the data from the matches from the regular expression and |
||
154 | * plug them into the result array per the info in the provided map. |
||
155 | * |
||
156 | * @param array $map |
||
157 | * An array mapping from result key to matches index. |
||
158 | * @param array $matches |
||
159 | * The matched strings returned from preg_match |
||
160 | * @return array |
||
161 | * @see parse() |
||
162 | */ |
||
163 | protected function mapResult($map, $matches) |
||
178 | |||
179 | /** |
||
180 | * Validate the provided result. If the result is local, then it must |
||
181 | * have a 'root'. If it does not, then fill in the root that was provided |
||
182 | * to us in our consturctor. |
||
183 | * |
||
184 | * @param array $result |
||
185 | * @see parse() result. |
||
186 | * @return array |
||
187 | * @see parse() |
||
188 | */ |
||
189 | protected function fixAndCheckUsability($result, $root) |
||
218 | } |
||
219 |