1 | <?php |
||
17 | class MultiDomainDomain extends Object |
||
18 | { |
||
19 | /** |
||
20 | * The hostname of the domain, e.g. silverstripe.org |
||
21 | * @var string |
||
22 | */ |
||
23 | protected $hostname; |
||
24 | |||
25 | /** |
||
26 | * The path that the hostname resolves to |
||
27 | * @var string |
||
28 | */ |
||
29 | protected $url; |
||
30 | |||
31 | /** |
||
32 | * The identifier of the domain, e.g. 'org','com' |
||
33 | * @var string |
||
34 | */ |
||
35 | protected $key; |
||
36 | |||
37 | /** |
||
38 | * Paths that are allowed to be accessed on the primary domain |
||
39 | * @var array |
||
40 | */ |
||
41 | protected $allowedPaths; |
||
42 | |||
43 | /** |
||
44 | * Paths that are forced from the primary domain into a vanity one, |
||
45 | * outside the resolves_to path |
||
46 | * |
||
47 | * @var array |
||
48 | */ |
||
49 | protected $forcedPaths; |
||
50 | |||
51 | /** |
||
52 | * The request URI |
||
53 | * |
||
54 | * @var string |
||
55 | */ |
||
56 | protected $requestUri; |
||
57 | |||
58 | /** |
||
59 | * The request HTTP HOST |
||
60 | * |
||
61 | * @var string |
||
62 | */ |
||
63 | protected $httpHost; |
||
64 | |||
65 | /** |
||
66 | * Constructor. Takes a key for the domain and its array of settings from the config |
||
67 | * @param string $key |
||
68 | * @param array $config |
||
69 | */ |
||
70 | public function __construct($key, $config) |
||
85 | |||
86 | /** |
||
87 | * Gets the hostname for the domain |
||
88 | * @return string |
||
89 | */ |
||
90 | public function getHostname() |
||
94 | |||
95 | /** |
||
96 | * Gets the path that the hostname resolves to |
||
97 | * @return string |
||
98 | */ |
||
99 | public function getURL() |
||
103 | |||
104 | /** |
||
105 | * Returns true if the domain is currently in the HTTP_HOST |
||
106 | * @return boolean |
||
107 | */ |
||
108 | public function isActive() |
||
126 | |||
127 | /** |
||
128 | * Returns true if this domain is the primary domain |
||
129 | * @return boolean |
||
130 | */ |
||
131 | public function isPrimary() |
||
135 | |||
136 | /** |
||
137 | * Gets the native URL for a vanity domain, e.g. /partners/ for .com |
||
138 | * returns /company/partners when .com is mapped to /company/. |
||
139 | * |
||
140 | * @param string $url |
||
141 | * @return string |
||
142 | */ |
||
143 | public function getNativeURL($url) |
||
155 | |||
156 | /** |
||
157 | * Gets the vanity URL given a native URL. /company/partners returns /partners/ |
||
158 | * when .com is mapped to /company/. |
||
159 | * |
||
160 | * @param string $url |
||
161 | * @return string |
||
162 | */ |
||
163 | public function getVanityURL($url) |
||
172 | |||
173 | /** |
||
174 | * Return true if this domain contains the given URL |
||
175 | * @param string $url |
||
176 | * @return boolean |
||
177 | */ |
||
178 | public function hasURL($url) |
||
190 | |||
191 | /** |
||
192 | * Returns the key/identifier for this domain |
||
193 | * |
||
194 | * @return string |
||
195 | */ |
||
196 | public function getKey() |
||
200 | |||
201 | /** |
||
202 | * Set the request URI |
||
203 | * |
||
204 | * @param string $requestUri |
||
205 | * @return $this |
||
206 | */ |
||
207 | public function setRequestUri($requestUri) |
||
212 | |||
213 | /** |
||
214 | * Return the current request URI, defaulting to retrieving it from the $_SERVER superglobal |
||
215 | * |
||
216 | * @return string |
||
217 | */ |
||
218 | public function getRequestUri() |
||
222 | |||
223 | /** |
||
224 | * Set the HTTP host in the request |
||
225 | * |
||
226 | * @param string $httpHost |
||
227 | * @return $this |
||
228 | */ |
||
229 | public function setHttpHost($httpHost) |
||
234 | |||
235 | /** |
||
236 | * Return the current HTTP host, defaulting to retrieving it from the $_SERVER superglobal |
||
237 | * |
||
238 | * @return string |
||
239 | */ |
||
240 | public function getHttpHost() |
||
244 | |||
245 | /** |
||
246 | * Checks a given list of wildcard patterns to see if a path is allowed |
||
247 | * @param string $url |
||
248 | * @return boolean |
||
249 | */ |
||
250 | protected function isAllowedPath($url) |
||
254 | |||
255 | /** |
||
256 | * Checks a given list of wildcard patterns to see if a path is allowed |
||
257 | * @param string $url |
||
258 | * @return boolean |
||
259 | */ |
||
260 | protected function isForcedPath($url) |
||
264 | |||
265 | /** |
||
266 | * Matches a URL against a list of wildcard patterns |
||
267 | * @param string $url |
||
268 | * @param array $patterns |
||
269 | * @return boolean |
||
270 | */ |
||
271 | protected static function match_url($url, $patterns) |
||
290 | } |
||
291 |
This checks looks for assignemnts to variables using the
list(...)
function, where not all assigned variables are subsequently used.Consider the following code example.
Only the variables
$a
and$c
are used. There was no need to assign$b
.Instead, the list call could have been.