@@ -23,8 +23,8 @@ |
||
23 | 23 | /*/ |
24 | 24 | |
25 | 25 | return array ( |
26 | - 'Multidimensional/Subdomains' => |
|
26 | + 'Multidimensional/Subdomains' => |
|
27 | 27 | array('subdomains' => |
28 | - array('{SUBDOMAIN_1}', '{SUBDOMAIN_2}', ... '{SUBDOMAIN_N}') |
|
29 | - ) |
|
28 | + array('{SUBDOMAIN_1}', '{SUBDOMAIN_2}', ... '{SUBDOMAIN_N}') |
|
29 | + ) |
|
30 | 30 | ); |
31 | 31 | \ No newline at end of file |
@@ -22,18 +22,18 @@ |
||
22 | 22 | |
23 | 23 | if ($validConfiguration) { |
24 | 24 | |
25 | - $subdomains = Configure::read('Multidimensional/Subdomains.subdomains'); |
|
25 | + $subdomains = Configure::read('Multidimensional/Subdomains.subdomains'); |
|
26 | 26 | |
27 | - if (is_array($subdomains)) { |
|
27 | + if (is_array($subdomains)) { |
|
28 | 28 | |
29 | - foreach ($subdomains AS $prefix) { |
|
29 | + foreach ($subdomains AS $prefix) { |
|
30 | 30 | |
31 | - Router::scope('/', ['prefix' => $prefix], function($routes) { |
|
32 | - $routes->fallbacks('InflectedRoute'); |
|
33 | - }); |
|
31 | + Router::scope('/', ['prefix' => $prefix], function($routes) { |
|
32 | + $routes->fallbacks('InflectedRoute'); |
|
33 | + }); |
|
34 | 34 | |
35 | - } |
|
35 | + } |
|
36 | 36 | |
37 | - } |
|
37 | + } |
|
38 | 38 | |
39 | - } |
|
40 | 39 | \ No newline at end of file |
40 | + } |
|
41 | 41 | \ No newline at end of file |
@@ -18,7 +18,7 @@ |
||
18 | 18 | use Cake\Console\Helper; |
19 | 19 | |
20 | 20 | class HeaderHelper extends Helper { |
21 | - public function output($args = null) { |
|
21 | + public function output ($args = null) { |
|
22 | 22 | $this->_io->out("\n\n"); |
23 | 23 | $this->_io->styles('header', ['text' => 'green']); |
24 | 24 |
@@ -20,129 +20,129 @@ |
||
20 | 20 | |
21 | 21 | class SubdomainsInstallShell extends Shell { |
22 | 22 | |
23 | - public function main() { |
|
23 | + public function main() { |
|
24 | 24 | |
25 | - $subdomains = array(); |
|
25 | + $subdomains = array(); |
|
26 | 26 | |
27 | - $this->clear(); |
|
27 | + $this->clear(); |
|
28 | 28 | |
29 | - $this->_io->styles('error', ['text' => 'red']); |
|
29 | + $this->_io->styles('error', ['text' => 'red']); |
|
30 | 30 | $this->helper('Multidimensional/Subdomains.Header')->output(); |
31 | 31 | |
32 | 32 | $first_run = Configure::check('Multidimensional/Subdomains.subdomains') ? false : true; |
33 | 33 | |
34 | - if ($first_run == false) { |
|
34 | + if ($first_run == false) { |
|
35 | 35 | |
36 | - $subdomains = Configure::consume('Multidimensional/Subdomains.subdomains'); |
|
36 | + $subdomains = Configure::consume('Multidimensional/Subdomains.subdomains'); |
|
37 | 37 | |
38 | - if (count($subdomains) == 0) { |
|
39 | - $first_run = true; |
|
40 | - } |
|
38 | + if (count($subdomains) == 0) { |
|
39 | + $first_run = true; |
|
40 | + } |
|
41 | 41 | |
42 | - } |
|
42 | + } |
|
43 | 43 | |
44 | 44 | if ((($first_run) ? (strtolower($this->in('Install Subdomains Plugin?', ['y', 'n'])) == 'y') : (strtolower($this->in('Update Configuration?', ['y', 'n'])) == 'y'))) { |
45 | 45 | |
46 | - do { |
|
46 | + do { |
|
47 | 47 | |
48 | - $this->out(); |
|
48 | + $this->out(); |
|
49 | 49 | |
50 | - $addMore = true; |
|
50 | + $addMore = true; |
|
51 | 51 | |
52 | - if ($first_run === false && count($subdomains) > 0) { |
|
52 | + if ($first_run === false && count($subdomains) > 0) { |
|
53 | 53 | |
54 | - $this->out('Current Subdomains:', 2); |
|
54 | + $this->out('Current Subdomains:', 2); |
|
55 | 55 | |
56 | - foreach ($subdomains AS $prefix) { |
|
57 | - $this->out(' - ' . $prefix); |
|
58 | - } |
|
56 | + foreach ($subdomains AS $prefix) { |
|
57 | + $this->out(' - ' . $prefix); |
|
58 | + } |
|
59 | 59 | |
60 | - $this->out(); |
|
60 | + $this->out(); |
|
61 | 61 | |
62 | - if (strtolower($this->in('Add Another Subdomain?', ['y', 'n'])) == 'n') { |
|
63 | - $addMore = false; |
|
64 | - } |
|
62 | + if (strtolower($this->in('Add Another Subdomain?', ['y', 'n'])) == 'n') { |
|
63 | + $addMore = false; |
|
64 | + } |
|
65 | 65 | |
66 | - } |
|
66 | + } |
|
67 | 67 | |
68 | - if ($addMore) { |
|
68 | + if ($addMore) { |
|
69 | 69 | |
70 | - if (count($subdomains) == 0) { |
|
71 | - $this->out('Add Your First Subdomain.'); |
|
72 | - } |
|
70 | + if (count($subdomains) == 0) { |
|
71 | + $this->out('Add Your First Subdomain.'); |
|
72 | + } |
|
73 | 73 | |
74 | - do { |
|
74 | + do { |
|
75 | 75 | |
76 | - $valid = true; |
|
77 | - $this->out(); |
|
78 | - $subdomain = $this->in('Subdomain:'); |
|
79 | - if (preg_match('/^[A-Za-z0-9]{1}(?:[A-Za-z0-9\-]{0,61}[A-Za-z0-9]{1})?$/', $subdomain, $matches)) { |
|
80 | - $subdomains[] = $subdomain; |
|
81 | - $valid = true; |
|
82 | - $this->out(); |
|
83 | - } else { |
|
84 | - $valid = false; |
|
85 | - $this->out(); |
|
86 | - $this->_io->out('<error>Invalid Subdomain.</error>'); |
|
87 | - } |
|
76 | + $valid = true; |
|
77 | + $this->out(); |
|
78 | + $subdomain = $this->in('Subdomain:'); |
|
79 | + if (preg_match('/^[A-Za-z0-9]{1}(?:[A-Za-z0-9\-]{0,61}[A-Za-z0-9]{1})?$/', $subdomain, $matches)) { |
|
80 | + $subdomains[] = $subdomain; |
|
81 | + $valid = true; |
|
82 | + $this->out(); |
|
83 | + } else { |
|
84 | + $valid = false; |
|
85 | + $this->out(); |
|
86 | + $this->_io->out('<error>Invalid Subdomain.</error>'); |
|
87 | + } |
|
88 | 88 | |
89 | - } while (!$valid || strtolower($this->in('Add Another Subdomain?', ['y', 'n'])) == 'y'); |
|
89 | + } while (!$valid || strtolower($this->in('Add Another Subdomain?', ['y', 'n'])) == 'y'); |
|
90 | 90 | |
91 | - } |
|
91 | + } |
|
92 | 92 | |
93 | - $subdomains = array_values(array_unique($subdomains)); |
|
93 | + $subdomains = array_values(array_unique($subdomains)); |
|
94 | 94 | |
95 | - $subdomains = $this->_modifyArray($subdomains); |
|
95 | + $subdomains = $this->_modifyArray($subdomains); |
|
96 | 96 | |
97 | - $this->out(); |
|
98 | - $this->out('Current Subdomains:', 2); |
|
97 | + $this->out(); |
|
98 | + $this->out('Current Subdomains:', 2); |
|
99 | 99 | |
100 | - if (count($subdomains) > 0) { |
|
101 | - foreach ($subdomains AS $key => $value) { |
|
102 | - $this->out(' ' . ($key) . '. ' . $value); |
|
103 | - } |
|
104 | - } |
|
100 | + if (count($subdomains) > 0) { |
|
101 | + foreach ($subdomains AS $key => $value) { |
|
102 | + $this->out(' ' . ($key) . '. ' . $value); |
|
103 | + } |
|
104 | + } |
|
105 | 105 | |
106 | - $this->out(); |
|
106 | + $this->out(); |
|
107 | 107 | |
108 | - while (count($subdomains) > 0 && strtolower($this->in('Delete a Subdomain?', ['y', 'n'])) == 'y') { |
|
108 | + while (count($subdomains) > 0 && strtolower($this->in('Delete a Subdomain?', ['y', 'n'])) == 'y') { |
|
109 | 109 | |
110 | - $this->out(); |
|
111 | - $deleteKey = (int) $this->in('Enter Number to Delete:', array_keys($subdomains)); |
|
110 | + $this->out(); |
|
111 | + $deleteKey = (int) $this->in('Enter Number to Delete:', array_keys($subdomains)); |
|
112 | 112 | |
113 | - if (isset($subdomains[$deleteKey])) { |
|
114 | - $this->out(); |
|
115 | - $this->out('Deleted: ' . $subdomains[$deleteKey], 2); |
|
116 | - unset($subdomains[$deleteKey]); |
|
117 | - } |
|
113 | + if (isset($subdomains[$deleteKey])) { |
|
114 | + $this->out(); |
|
115 | + $this->out('Deleted: ' . $subdomains[$deleteKey], 2); |
|
116 | + unset($subdomains[$deleteKey]); |
|
117 | + } |
|
118 | 118 | |
119 | - } |
|
119 | + } |
|
120 | 120 | |
121 | - Configure::write('Multidimensional/Subdomains.subdomains', array_values($subdomains)); |
|
122 | - Configure::dump('subdomains', 'default', ['Multidimensional/Subdomains']); |
|
121 | + Configure::write('Multidimensional/Subdomains.subdomains', array_values($subdomains)); |
|
122 | + Configure::dump('subdomains', 'default', ['Multidimensional/Subdomains']); |
|
123 | 123 | |
124 | - if (count($subdomains) == 0) { |
|
125 | - $this->out(); |
|
126 | - $this->_io->out('<error>No Subdomains Configured.</error>', 2); |
|
127 | - } |
|
124 | + if (count($subdomains) == 0) { |
|
125 | + $this->out(); |
|
126 | + $this->_io->out('<error>No Subdomains Configured.</error>', 2); |
|
127 | + } |
|
128 | 128 | |
129 | - } while (count($subdomains) == 0 && strtolower($this->in('Start Over?', ['y', 'n'])) == 'y'); |
|
129 | + } while (count($subdomains) == 0 && strtolower($this->in('Start Over?', ['y', 'n'])) == 'y'); |
|
130 | 130 | |
131 | - $this->out(); |
|
132 | - if (count($subdomains) > 0) { |
|
133 | - $this->out('Configuration Saved!', 2); |
|
134 | - } else { |
|
135 | - $this->_io->out('<error>Plugin Not Currently Active.</error>', 2); |
|
136 | - } |
|
137 | - } |
|
131 | + $this->out(); |
|
132 | + if (count($subdomains) > 0) { |
|
133 | + $this->out('Configuration Saved!', 2); |
|
134 | + } else { |
|
135 | + $this->_io->out('<error>Plugin Not Currently Active.</error>', 2); |
|
136 | + } |
|
137 | + } |
|
138 | 138 | |
139 | - } |
|
139 | + } |
|
140 | 140 | |
141 | - private function _modifyArray(array $array) { |
|
141 | + private function _modifyArray(array $array) { |
|
142 | 142 | |
143 | - return array_combine(range(1, count($array)), array_values($array)); ; |
|
143 | + return array_combine(range(1, count($array)), array_values($array)); ; |
|
144 | 144 | |
145 | - } |
|
145 | + } |
|
146 | 146 | |
147 | 147 | |
148 | 148 | } |
149 | 149 | \ No newline at end of file |
@@ -20,7 +20,7 @@ discard block |
||
20 | 20 | |
21 | 21 | class SubdomainsInstallShell extends Shell { |
22 | 22 | |
23 | - public function main() { |
|
23 | + public function main () { |
|
24 | 24 | |
25 | 25 | $subdomains = array(); |
26 | 26 | |
@@ -138,7 +138,7 @@ discard block |
||
138 | 138 | |
139 | 139 | } |
140 | 140 | |
141 | - private function _modifyArray(array $array) { |
|
141 | + private function _modifyArray (array $array) { |
|
142 | 142 | |
143 | 143 | return array_combine(range(1, count($array)), array_values($array)); ; |
144 | 144 |
@@ -21,7 +21,7 @@ discard block |
||
21 | 21 | |
22 | 22 | trait SubdomainRouteTrait { |
23 | 23 | |
24 | - private function _getSubdomains() { |
|
24 | + private function _getSubdomains () { |
|
25 | 25 | |
26 | 26 | $validConfiguration = Configure::check('Multidimensional/Subdomains.subdomains'); |
27 | 27 | |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | |
40 | 40 | } |
41 | 41 | |
42 | - private function _getPrefixAndHost(array $context = []) { |
|
42 | + private function _getPrefixAndHost (array $context = []) { |
|
43 | 43 | if (empty($context['_host'])) { |
44 | 44 | $request = Router::getRequest(true) ?: Request::createFromGlobals(); |
45 | 45 | $host = $request->host(); |
@@ -54,12 +54,12 @@ discard block |
||
54 | 54 | } |
55 | 55 | } |
56 | 56 | |
57 | - private function _checkPrefix($prefix) { |
|
57 | + private function _checkPrefix ($prefix) { |
|
58 | 58 | $routePrefix = isset($this->defaults['prefix']) ? $this->defaults['prefix'] : false; |
59 | 59 | return $prefix === $routePrefix; |
60 | 60 | } |
61 | 61 | |
62 | - public function parse($url, $method = '') { |
|
62 | + public function parse ($url, $method = '') { |
|
63 | 63 | list($prefix) = $this->_getPrefixAndHost(); |
64 | 64 | if (!$this->_checkPrefix($prefix)) { |
65 | 65 | return false; |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | return parent::parse($url, $method); |
68 | 68 | } |
69 | 69 | |
70 | - public function match(array $url, array $context = []) { |
|
70 | + public function match (array $url, array $context = []) { |
|
71 | 71 | if (!isset($url['prefix'])) { |
72 | 72 | $url['prefix'] = false; |
73 | 73 | } |