Completed
Branch master (f15b87)
by AJ
04:52
created
src/Routing/SubdomainRouteTrait.php 2 patches
Unused Use Statements   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -15,7 +15,7 @@
 block discarded – undo
15 15
  
16 16
 namespace Multidimensional\Subdomains\Routing;
17 17
 
18
-use Cake\Network\Request; 
18
+use Cake\Network\Request;
19 19
 use Cake\Routing\Router;
20 20
 use Cake\Core\Configure;
21 21
 
Please login to merge, or discard this patch.
Indentation   +38 added lines, -38 removed lines patch added patch discarded remove patch
@@ -40,45 +40,45 @@
 block discarded – undo
40 40
 		
41 41
 	}
42 42
 
43
-    private function _getPrefixAndHost(array $context = []) {
44
-        if (empty($context['_host'])) {
45
-            $request = Router::getRequest(true) ?: Request::createFromGlobals();
46
-            $host = $request->host();
47
-        } else {
48
-            $host = $context['_host'];
49
-        }
50
-        $parts = explode('.', $host, 2);
51
-        if (in_array($parts[0], $this->_getSubdomains())) {
52
-            return $parts;
53
-        } else {
54
-            return [false, $host];
55
-        }
56
-    }
43
+	private function _getPrefixAndHost(array $context = []) {
44
+		if (empty($context['_host'])) {
45
+			$request = Router::getRequest(true) ?: Request::createFromGlobals();
46
+			$host = $request->host();
47
+		} else {
48
+			$host = $context['_host'];
49
+		}
50
+		$parts = explode('.', $host, 2);
51
+		if (in_array($parts[0], $this->_getSubdomains())) {
52
+			return $parts;
53
+		} else {
54
+			return [false, $host];
55
+		}
56
+	}
57 57
 
58
-    private function _checkPrefix($prefix) {
59
-        $routePrefix = isset($this->defaults['prefix']) ? $this->defaults['prefix'] : false;
60
-        return $prefix === $routePrefix;
61
-    }
58
+	private function _checkPrefix($prefix) {
59
+		$routePrefix = isset($this->defaults['prefix']) ? $this->defaults['prefix'] : false;
60
+		return $prefix === $routePrefix;
61
+	}
62 62
 
63
-    public function parse($url, $method = '') {
64
-        list($prefix) = $this->_getPrefixAndHost();
65
-        if (!$this->_checkPrefix($prefix)) {
66
-            return false;
67
-        }
68
-        return parent::parse($url, $method);
69
-    }
63
+	public function parse($url, $method = '') {
64
+		list($prefix) = $this->_getPrefixAndHost();
65
+		if (!$this->_checkPrefix($prefix)) {
66
+			return false;
67
+		}
68
+		return parent::parse($url, $method);
69
+	}
70 70
 
71
-    public function match(array $url, array $context = []) {
72
-        if (!isset($url['prefix'])) {
73
-            $url['prefix'] = false;
74
-        }
75
-        if (!$this->_checkPrefix($url['prefix'])) {
76
-            return false;
77
-        }
78
-        list($prefix, $host) = $this->_getPrefixAndHost($context);
79
-        if ($prefix !== $url['prefix']) {
80
-            $url['_host'] = $url['prefix'] === false ? $host : $url['prefix'] . '.' . $host;
81
-        }
82
-        return parent::match($url, $context);
83
-    }
71
+	public function match(array $url, array $context = []) {
72
+		if (!isset($url['prefix'])) {
73
+			$url['prefix'] = false;
74
+		}
75
+		if (!$this->_checkPrefix($url['prefix'])) {
76
+			return false;
77
+		}
78
+		list($prefix, $host) = $this->_getPrefixAndHost($context);
79
+		if ($prefix !== $url['prefix']) {
80
+			$url['_host'] = $url['prefix'] === false ? $host : $url['prefix'] . '.' . $host;
81
+		}
82
+		return parent::match($url, $context);
83
+	}
84 84
 }
Please login to merge, or discard this patch.
src/Shell/SubdomainsInstallShell.php 4 patches
Unused Use Statements   -1 removed lines patch added patch discarded remove patch
@@ -17,7 +17,6 @@
 block discarded – undo
17 17
 
18 18
 use Cake\Core\Configure;
19 19
 use Cake\Console\Shell;
20
-use Cake\Console\Helper;
21 20
 
22 21
 class SubdomainsInstallShell extends Shell {
23 22
     
Please login to merge, or discard this patch.
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -25,12 +25,12 @@  discard block
 block discarded – undo
25 25
 	
26 26
 		$subdomains = array();	
27 27
 	
28
-	    $this->clear();
28
+		$this->clear();
29 29
 		
30 30
 		$this->_io->styles('error', ['text' => 'red']);
31
-        $this->helper('Multidimensional/Subdomains.Header')->output();
31
+		$this->helper('Multidimensional/Subdomains.Header')->output();
32 32
     
33
-        $first_run = Configure::check('Multidimensional/Subdomains.subdomains') ? false : true;
33
+		$first_run = Configure::check('Multidimensional/Subdomains.subdomains') ? false : true;
34 34
 		
35 35
 		if ($first_run == false) {
36 36
 			
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
42 42
 			
43 43
 		}
44 44
 	   
45
-        if ((($first_run) ? (strtolower($this->in('Install Subdomains Plugin?', ['y','n'])) == 'y') : (strtolower($this->in('Update Configuration?', ['y','n'])) == 'y'))) {
45
+		if ((($first_run) ? (strtolower($this->in('Install Subdomains Plugin?', ['y','n'])) == 'y') : (strtolower($this->in('Update Configuration?', ['y','n'])) == 'y'))) {
46 46
 			
47 47
 			do {
48 48
 				
Please login to merge, or discard this patch.
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
42 42
 			
43 43
 		}
44 44
 	   
45
-        if ((($first_run) ? (strtolower($this->in('Install Subdomains Plugin?', ['y','n'])) == 'y') : (strtolower($this->in('Update Configuration?', ['y','n'])) == 'y'))) {
45
+        if ((($first_run) ? (strtolower($this->in('Install Subdomains Plugin?', ['y', 'n'])) == 'y') : (strtolower($this->in('Update Configuration?', ['y', 'n'])) == 'y'))) {
46 46
 			
47 47
 			do {
48 48
 				
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
 					
61 61
 					$this->out();
62 62
 					
63
-					if (strtolower($this->in('Add Another Subdomain?', ['y','n'])) == 'n') {
63
+					if (strtolower($this->in('Add Another Subdomain?', ['y', 'n'])) == 'n') {
64 64
 						$addMore = false;
65 65
 					}
66 66
 									
@@ -81,13 +81,13 @@  discard block
 block discarded – undo
81 81
 							$subdomains[] = $subdomain;
82 82
 							$valid = true;
83 83
 							$this->out();
84
-						}else{
84
+						} else {
85 85
 							$valid = false;
86 86
 							$this->out();
87 87
 							$this->_io->out('<error>Invalid Subdomain.</error>');
88 88
 						}
89 89
 						
90
-					} while (!$valid || strtolower($this->in('Add Another Subdomain?', ['y','n'])) == 'y');
90
+					} while (!$valid || strtolower($this->in('Add Another Subdomain?', ['y', 'n'])) == 'y');
91 91
 					
92 92
 				}
93 93
 				
@@ -106,14 +106,14 @@  discard block
 block discarded – undo
106 106
 				
107 107
 				$this->out();
108 108
 							
109
-				while (count($subdomains) > 0 && strtolower($this->in('Delete a Subdomain?', ['y','n'])) == 'y') {
109
+				while (count($subdomains) > 0 && strtolower($this->in('Delete a Subdomain?', ['y', 'n'])) == 'y') {
110 110
 					
111 111
 					$this->out();
112 112
 					$deleteKey = (int) $this->in('Enter Number to Delete:', array_keys($subdomains));
113 113
 					
114 114
 					if (isset($subdomains[$deleteKey])) {
115 115
 						$this->out();
116
-						$this->out('Deleted: ' .  $subdomains[$deleteKey], 2);
116
+						$this->out('Deleted: ' . $subdomains[$deleteKey], 2);
117 117
 						unset($subdomains[$deleteKey]);	
118 118
 					}
119 119
 					
@@ -127,10 +127,10 @@  discard block
 block discarded – undo
127 127
 					$this->_io->out('<error>No Subdomains Configured.</error>', 2);					
128 128
 				}
129 129
 				
130
-			} while (count($subdomains) == 0 && strtolower($this->in('Start Over?', ['y','n'])) == 'y');
130
+			} while (count($subdomains) == 0 && strtolower($this->in('Start Over?', ['y', 'n'])) == 'y');
131 131
 			
132 132
 			$this->out();
133
-			if(count($subdomains) > 0) {
133
+			if (count($subdomains) > 0) {
134 134
 				$this->out('Configuration Saved!', 2);
135 135
 			} else {
136 136
 				$this->_io->out('<error>Plugin Not Currently Active.</error>', 2);	
@@ -141,7 +141,7 @@  discard block
 block discarded – undo
141 141
 	
142 142
 	private function _modifyArray(array $array) {
143 143
 
144
-		return array_combine(range(1, count($array)), array_values($array));;	
144
+		return array_combine(range(1, count($array)), array_values($array)); ;	
145 145
 		
146 146
 	}
147 147
 	  
Please login to merge, or discard this patch.
Braces   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -81,7 +81,7 @@
 block discarded – undo
81 81
 							$subdomains[] = $subdomain;
82 82
 							$valid = true;
83 83
 							$this->out();
84
-						}else{
84
+						} else{
85 85
 							$valid = false;
86 86
 							$this->out();
87 87
 							$this->_io->out('<error>Invalid Subdomain.</error>');
Please login to merge, or discard this patch.
config/subdomains.default.php 2 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -24,7 +24,7 @@
 block discarded – undo
24 24
 
25 25
 return array (
26 26
   'Multidimensional/Subdomains' => 
27
-    array('subdomains' =>
27
+	array('subdomains' =>
28 28
 		array('{SUBDOMAIN_1}', '{SUBDOMAIN_2}', ... '{SUBDOMAIN_N}')
29 29
 	)
30 30
 );
31 31
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -22,7 +22,7 @@
 block discarded – undo
22 22
  *  If you don't have this file, copy it to your main CakePHP config folder.
23 23
 /*/
24 24
 
25
-return array (
25
+return array(
26 26
   'Multidimensional/Subdomains' => 
27 27
     array('subdomains' =>
28 28
 		array('{SUBDOMAIN_1}', '{SUBDOMAIN_2}', ... '{SUBDOMAIN_N}')
Please login to merge, or discard this patch.
config/routes.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -24,7 +24,7 @@
 block discarded – undo
24 24
 
25 25
 	$subdomains = Configure::read('Multidimensional/Subdomains.subdomains');
26 26
 	
27
-	if(is_array($subdomains)) {
27
+	if (is_array($subdomains)) {
28 28
 		
29 29
 		foreach ($subdomains AS $prefix) {
30 30
 			
Please login to merge, or discard this patch.
src/Routing/Route/DashedRoute.php 1 patch
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -20,5 +20,5 @@
 block discarded – undo
20 20
 
21 21
 class DashedRoute extends CakeDashedRoute
22 22
 {
23
-    use SubdomainRouteTrait;
23
+	use SubdomainRouteTrait;
24 24
 }
25 25
\ No newline at end of file
Please login to merge, or discard this patch.
src/Routing/Route/Route.php 1 patch
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -20,5 +20,5 @@
 block discarded – undo
20 20
 
21 21
 class Route extends CakeRoute
22 22
 {
23
-    use SubdomainRouteTrait;
23
+	use SubdomainRouteTrait;
24 24
 }
25 25
\ No newline at end of file
Please login to merge, or discard this patch.
src/Routing/Route/InflectedRoute.php 1 patch
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -20,5 +20,5 @@
 block discarded – undo
20 20
 
21 21
 class InflectedRoute extends CakeInflectedRoute
22 22
 {
23
-    use SubdomainRouteTrait;
23
+	use SubdomainRouteTrait;
24 24
 }
25 25
\ No newline at end of file
Please login to merge, or discard this patch.
src/Shell/Helper/HeaderHelper.php 1 patch
Indentation   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -19,19 +19,19 @@
 block discarded – undo
19 19
 
20 20
 class HeaderHelper extends Helper
21 21
 {
22
-    public function output($args = null)
23
-    {
24
-        $this->_io->out("\n\n");
25
-        $this->_io->styles('header', ['text' => 'green']);
22
+	public function output($args = null)
23
+	{
24
+		$this->_io->out("\n\n");
25
+		$this->_io->styles('header', ['text' => 'green']);
26 26
 
27
-        $this->_io->out('<header>   ______  _____  ___  ____  __  ______   _____  ______</header>');
27
+		$this->_io->out('<header>   ______  _____  ___  ____  __  ______   _____  ______</header>');
28 28
 		$this->_io->out('<header>  / __/ / / / _ )/ _ \/ __ \/  |/  / _ | /  _/ |/ / __/</header>');
29 29
 		$this->_io->out('<header> _\ \/ /_/ / _  / // / /_/ / /|_/ / __ |_/ //    /\ \  </header>');
30 30
 		$this->_io->out('<header>/___/\____/____/____/\____/_/  /_/_/ |_/___/_/|_/___/  </header>');
31
-        $this->_io->out("\n");
32
-        $this->_io->out('<header>              CakePHP : Subdomains Router              </header>');
33
-        $this->_io->out('<header>              by https://multidimension.al             </header>');
34
-        $this->_io->out("\n\n");
35
-    }
31
+		$this->_io->out("\n");
32
+		$this->_io->out('<header>              CakePHP : Subdomains Router              </header>');
33
+		$this->_io->out('<header>              by https://multidimension.al             </header>');
34
+		$this->_io->out("\n\n");
35
+	}
36 36
     
37 37
 }
Please login to merge, or discard this patch.