1 | <?php |
||
9 | class MultiDomainDomain extends Object { |
||
|
|||
10 | |||
11 | /** |
||
12 | * The hostname of the domain, e.g. silverstripe.org |
||
13 | * @var string |
||
14 | */ |
||
15 | protected $hostname; |
||
16 | |||
17 | /** |
||
18 | * The path that the hostname resolves to |
||
19 | * @var string |
||
20 | */ |
||
21 | protected $url; |
||
22 | |||
23 | /** |
||
24 | * The identifier of the domain, e.g. 'org','com' |
||
25 | * @var string |
||
26 | */ |
||
27 | protected $key; |
||
28 | |||
29 | /** |
||
30 | * Paths that are allowed to be accessed on the primary domain |
||
31 | * @var array |
||
32 | */ |
||
33 | protected $allowedPaths; |
||
34 | |||
35 | /** |
||
36 | * Paths that are forced from the primary domain into a vanity one, |
||
37 | * outside the resolves_to path |
||
38 | * |
||
39 | * @var array |
||
40 | */ |
||
41 | protected $forcedPaths; |
||
42 | |||
43 | /** |
||
44 | * The request URI |
||
45 | * |
||
46 | * @var string |
||
47 | */ |
||
48 | protected $requestUri; |
||
49 | |||
50 | /** |
||
51 | * The request HTTP HOST |
||
52 | * |
||
53 | * @var string |
||
54 | */ |
||
55 | protected $httpHost; |
||
56 | |||
57 | /** |
||
58 | * Constructor. Takes a key for the domain and its array of settings from the config |
||
59 | * @param string $key |
||
60 | * @param array $config |
||
61 | */ |
||
62 | public function __construct($key, $config) { |
||
76 | |||
77 | /** |
||
78 | * Gets the hostname for the domain |
||
79 | * @return string |
||
80 | */ |
||
81 | public function getHostname() { |
||
84 | |||
85 | /** |
||
86 | * Gets the path that the hostname resolves to |
||
87 | * @return string |
||
88 | */ |
||
89 | public function getURL() { |
||
92 | |||
93 | /** |
||
94 | * Returns true if the domain is currently in the HTTP_HOST |
||
95 | * @return boolean |
||
96 | */ |
||
97 | public function isActive() { |
||
114 | |||
115 | /** |
||
116 | * Returns true if this domain is the primary domain |
||
117 | * @return boolean |
||
118 | */ |
||
119 | public function isPrimary() { |
||
122 | |||
123 | /** |
||
124 | * Gets the native URL for a vanity domain, e.g. /partners/ for .com |
||
125 | * returns /company/partners when .com is mapped to /company/. |
||
126 | * |
||
127 | * @param string $url |
||
128 | * @return string |
||
129 | */ |
||
130 | public function getNativeURL($url) { |
||
141 | |||
142 | /** |
||
143 | * Gets the vanity URL given a native URL. /company/partners returns /partners/ |
||
144 | * when .com is mapped to /company/. |
||
145 | * |
||
146 | * @param string $url |
||
147 | * @return string |
||
148 | */ |
||
149 | public function getVanityURL($url) { |
||
157 | |||
158 | /** |
||
159 | * Return true if this domain contains the given URL |
||
160 | * @param string $url |
||
161 | * @return boolean |
||
162 | */ |
||
163 | public function hasURL($url) { |
||
172 | |||
173 | /** |
||
174 | * Returns the key/identifier for this domain |
||
175 | * |
||
176 | * @return string |
||
177 | */ |
||
178 | public function getKey() |
||
182 | |||
183 | /** |
||
184 | * Set the request URI |
||
185 | * |
||
186 | * @param string $requestUri |
||
187 | * @return $this |
||
188 | */ |
||
189 | public function setRequestUri($requestUri) |
||
194 | |||
195 | /** |
||
196 | * Return the current request URI, defaulting to retrieving it from the $_SERVER superglobal |
||
197 | * |
||
198 | * @return string |
||
199 | */ |
||
200 | public function getRequestUri() |
||
204 | |||
205 | /** |
||
206 | * Set the HTTP host in the request |
||
207 | * |
||
208 | * @param string $httpHost |
||
209 | * @return $this |
||
210 | */ |
||
211 | public function setHttpHost($httpHost) |
||
216 | |||
217 | /** |
||
218 | * Return the current HTTP host, defaulting to retrieving it from the $_SERVER superglobal |
||
219 | * |
||
220 | * @return string |
||
221 | */ |
||
222 | public function getHttpHost() |
||
226 | |||
227 | /** |
||
228 | * Checks a given list of wildcard patterns to see if a path is allowed |
||
229 | * @param string $url |
||
230 | * @return boolean |
||
231 | */ |
||
232 | protected function isAllowedPath($url) { |
||
235 | |||
236 | /** |
||
237 | * Checks a given list of wildcard patterns to see if a path is allowed |
||
238 | * @param string $url |
||
239 | * @return boolean |
||
240 | */ |
||
241 | protected function isForcedPath($url) { |
||
244 | |||
245 | /** |
||
246 | * Matches a URL against a list of wildcard patterns |
||
247 | * @param string $url |
||
248 | * @param array $patterns |
||
249 | * @return boolean |
||
250 | */ |
||
251 | protected static function match_url($url, $patterns) { |
||
263 | |||
264 | } |
||
265 |
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.