Passed
Push — develop ( 93fa30...bf4d93 )
by Andrew
06:14
created
src/controllers/TablesController.php 1 patch
Spacing   +39 added lines, -39 removed lines patch added patch discarded remove patch
@@ -63,7 +63,7 @@  discard block
 block discarded – undo
63 63
         $siteId = 0
64 64
     ): Response {
65 65
         PermissionHelper::controllerPermissionCheck('retour:dashboard');
66
-        $data = [];
66
+        $data = [ ];
67 67
         $sortField = 'hitCount';
68 68
         $sortType = 'DESC';
69 69
         // Figure out the sorting type
@@ -77,42 +77,42 @@  discard block
 block discarded – undo
77 77
         // Query the db table
78 78
         $offset = ($page - 1) * $per_page;
79 79
         $query = (new Query())
80
-            ->from(['{{%retour_stats}}'])
80
+            ->from([ '{{%retour_stats}}' ])
81 81
             ->offset($offset)
82 82
             ->limit($per_page)
83 83
             ->orderBy("{$sortField} {$sortType}");
84
-        if ((int)$siteId !== 0) {
85
-            $query->where(['siteId' => $siteId]);
84
+        if ((int) $siteId !== 0) {
85
+            $query->where([ 'siteId' => $siteId ]);
86 86
         }
87 87
         if ($filter !== '') {
88
-            $query->where(['like', 'redirectSrcUrl', $filter]);
89
-            $query->orWhere(['like', 'referrerUrl', $filter]);
88
+            $query->where([ 'like', 'redirectSrcUrl', $filter ]);
89
+            $query->orWhere([ 'like', 'referrerUrl', $filter ]);
90 90
         }
91 91
         $stats = $query->all();
92 92
         if ($stats) {
93 93
             // Add in the `addLink` field
94 94
             foreach ($stats as &$stat) {
95
-                $stat['addLink'] = '';
96
-                if (!$stat['handledByRetour']) {
97
-                    $encodedUrl = urlencode('/'.ltrim($stat['redirectSrcUrl'], '/'));
98
-                    $stat['addLink'] = UrlHelper::cpUrl('retour/add-redirect', [
95
+                $stat[ 'addLink' ] = '';
96
+                if (!$stat[ 'handledByRetour' ]) {
97
+                    $encodedUrl = urlencode('/' . ltrim($stat[ 'redirectSrcUrl' ], '/'));
98
+                    $stat[ 'addLink' ] = UrlHelper::cpUrl('retour/add-redirect', [
99 99
                         'defaultUrl' => $encodedUrl
100 100
                     ]);
101 101
                 }
102 102
             }
103 103
             // Format the data for the API
104
-            $data['data'] = $stats;
104
+            $data[ 'data' ] = $stats;
105 105
             $query = (new Query())
106
-                ->from(['{{%retour_stats}}']);
107
-            if ((int)$siteId !== 0) {
108
-                $query->where(['siteId' => $siteId]);
106
+                ->from([ '{{%retour_stats}}' ]);
107
+            if ((int) $siteId !== 0) {
108
+                $query->where([ 'siteId' => $siteId ]);
109 109
             }
110 110
             if ($filter !== '') {
111
-                $query->where(['like', 'redirectSrcUrl', $filter]);
112
-                $query->orWhere(['like', 'referrerUrl', $filter]);
111
+                $query->where([ 'like', 'redirectSrcUrl', $filter ]);
112
+                $query->orWhere([ 'like', 'referrerUrl', $filter ]);
113 113
             }
114 114
             $count = $query->count();
115
-            $data['links']['pagination'] = [
115
+            $data[ 'links' ][ 'pagination' ] = [
116 116
                 'total' => $count,
117 117
                 'per_page' => $per_page,
118 118
                 'current_page' => $page,
@@ -147,7 +147,7 @@  discard block
 block discarded – undo
147 147
         $siteId = 0
148 148
     ): Response {
149 149
         PermissionHelper::controllerPermissionCheck('retour:redirects');
150
-        $data = [];
150
+        $data = [ ];
151 151
         $sortField = 'hitCount';
152 152
         $sortType = 'DESC';
153 153
         // Figure out the sorting type
@@ -161,53 +161,53 @@  discard block
 block discarded – undo
161 161
         // Query the db table
162 162
         $offset = ($page - 1) * $per_page;
163 163
         $query = (new Query())
164
-            ->from(['{{%retour_static_redirects}}'])
164
+            ->from([ '{{%retour_static_redirects}}' ])
165 165
             ->offset($offset)
166 166
             ->limit($per_page)
167 167
             ->orderBy("{$sortField} {$sortType}");
168
-        if ((int)$siteId !== 0) {
169
-            $query->where(['siteId' => $siteId]);
168
+        if ((int) $siteId !== 0) {
169
+            $query->where([ 'siteId' => $siteId ]);
170 170
         }
171 171
         if ($filter !== '') {
172
-            $query->where(['like', 'redirectSrcUrl', $filter]);
173
-            $query->orWhere(['like', 'redirectDestUrl', $filter]);
172
+            $query->where([ 'like', 'redirectSrcUrl', $filter ]);
173
+            $query->orWhere([ 'like', 'redirectDestUrl', $filter ]);
174 174
         }
175 175
         $redirects = $query->all();
176 176
         // Add in the `deleteLink` field and clean up the redirects
177 177
         foreach ($redirects as &$redirect) {
178 178
             // Make sure the destination URL is not a regex
179
-            if ($redirect['redirectMatchType'] !== 'exactmatch') {
180
-                if (preg_match("/\$\d+/", $redirect['redirectDestUrl'])) {
181
-                    $redirect['redirectDestUrl'] = '';
179
+            if ($redirect[ 'redirectMatchType' ] !== 'exactmatch') {
180
+                if (preg_match("/\$\d+/", $redirect[ 'redirectDestUrl' ])) {
181
+                    $redirect[ 'redirectDestUrl' ] = '';
182 182
                 }
183 183
             }
184 184
             // Handle extracting the site name
185
-            $redirect['siteName'] = Craft::t('retour', 'All Sites');
186
-            if ($redirect['siteId']) {
185
+            $redirect[ 'siteName' ] = Craft::t('retour', 'All Sites');
186
+            if ($redirect[ 'siteId' ]) {
187 187
                 $sites = Craft::$app->getSites();
188
-                $site = $sites->getSiteById($redirect['siteId']);
188
+                $site = $sites->getSiteById($redirect[ 'siteId' ]);
189 189
                 if ($site) {
190
-                    $redirect['siteName'] = $site->name;
190
+                    $redirect[ 'siteName' ] = $site->name;
191 191
                 }
192 192
             }
193 193
 
194
-            $redirect['deleteLink'] = UrlHelper::cpUrl('retour/delete-redirect/'.$redirect['id']);
195
-            $redirect['editLink'] = UrlHelper::cpUrl('retour/edit-redirect/'.$redirect['id']);
194
+            $redirect[ 'deleteLink' ] = UrlHelper::cpUrl('retour/delete-redirect/' . $redirect[ 'id' ]);
195
+            $redirect[ 'editLink' ] = UrlHelper::cpUrl('retour/edit-redirect/' . $redirect[ 'id' ]);
196 196
         }
197 197
         // Format the data for the API
198 198
         if ($redirects) {
199
-            $data['data'] = $redirects;
199
+            $data[ 'data' ] = $redirects;
200 200
             $query = (new Query())
201
-                ->from(['{{%retour_static_redirects}}']);
202
-            if ((int)$siteId !== 0) {
203
-                $query->where(['siteId' => $siteId]);
201
+                ->from([ '{{%retour_static_redirects}}' ]);
202
+            if ((int) $siteId !== 0) {
203
+                $query->where([ 'siteId' => $siteId ]);
204 204
             }
205 205
             if ($filter !== '') {
206
-                $query->where(['like', 'redirectSrcUrl', $filter]);
207
-                $query->orWhere(['like', 'redirectDestUrl', $filter]);
206
+                $query->where([ 'like', 'redirectSrcUrl', $filter ]);
207
+                $query->orWhere([ 'like', 'redirectDestUrl', $filter ]);
208 208
             }
209 209
             $count = $query->count();
210
-            $data['links']['pagination'] = [
210
+            $data[ 'links' ][ 'pagination' ] = [
211 211
                 'total' => $count,
212 212
                 'per_page' => $per_page,
213 213
                 'current_page' => $page,
Please login to merge, or discard this patch.