Passed
Push — develop ( 659688...6dbe61 )
by Andrew
05:18
created
src/controllers/TablesController.php 1 patch
Spacing   +40 added lines, -40 removed lines patch added patch discarded remove patch
@@ -70,7 +70,7 @@  discard block
 block discarded – undo
70 70
         $handled = 'all'
71 71
     ): Response {
72 72
         PermissionHelper::controllerPermissionCheck('retour:dashboard');
73
-        $data = [];
73
+        $data = [ ];
74 74
         $sortField = 'hitCount';
75 75
         $sortType = 'DESC';
76 76
         // Figure out the sorting type
@@ -84,48 +84,48 @@  discard block
 block discarded – undo
84 84
         // Query the db table
85 85
         $offset = ($page - 1) * $per_page;
86 86
         $query = (new Query())
87
-            ->from(['{{%retour_stats}}'])
87
+            ->from([ '{{%retour_stats}}' ])
88 88
             ->offset($offset)
89 89
             ->limit($per_page)
90 90
             ->orderBy("{$sortField} {$sortType}");
91
-        if ((int)$siteId !== 0) {
92
-            $query->where(['siteId' => $siteId]);
91
+        if ((int) $siteId !== 0) {
92
+            $query->where([ 'siteId' => $siteId ]);
93 93
         }
94 94
         if ($handled !== 'all') {
95
-            $query->where(['handledByRetour' => self::HANDLED_MAP[$handled]]);
95
+            $query->where([ 'handledByRetour' => self::HANDLED_MAP[ $handled ] ]);
96 96
         }
97 97
         if ($filter !== '') {
98
-            $query->where(['like', 'redirectSrcUrl', $filter]);
99
-            $query->orWhere(['like', 'referrerUrl', $filter]);
98
+            $query->where([ 'like', 'redirectSrcUrl', $filter ]);
99
+            $query->orWhere([ 'like', 'referrerUrl', $filter ]);
100 100
         }
101 101
         $stats = $query->all();
102 102
         if ($stats) {
103 103
             // Add in the `addLink` field
104 104
             foreach ($stats as &$stat) {
105
-                $stat['addLink'] = '';
106
-                if (!$stat['handledByRetour']) {
107
-                    $encodedUrl = urlencode('/'.ltrim($stat['redirectSrcUrl'], '/'));
108
-                    $stat['addLink'] = UrlHelper::cpUrl('retour/add-redirect', [
105
+                $stat[ 'addLink' ] = '';
106
+                if (!$stat[ 'handledByRetour' ]) {
107
+                    $encodedUrl = urlencode('/' . ltrim($stat[ 'redirectSrcUrl' ], '/'));
108
+                    $stat[ 'addLink' ] = UrlHelper::cpUrl('retour/add-redirect', [
109 109
                         'defaultUrl' => $encodedUrl
110 110
                     ]);
111 111
                 }
112 112
             }
113 113
             // Format the data for the API
114
-            $data['data'] = $stats;
114
+            $data[ 'data' ] = $stats;
115 115
             $query = (new Query())
116
-                ->from(['{{%retour_stats}}']);
117
-            if ((int)$siteId !== 0) {
118
-                $query->where(['siteId' => $siteId]);
116
+                ->from([ '{{%retour_stats}}' ]);
117
+            if ((int) $siteId !== 0) {
118
+                $query->where([ 'siteId' => $siteId ]);
119 119
             }
120 120
             if ($handled !== 'all') {
121
-                $query->where(['handledByRetour' => self::HANDLED_MAP[$handled]]);
121
+                $query->where([ 'handledByRetour' => self::HANDLED_MAP[ $handled ] ]);
122 122
             }
123 123
             if ($filter !== '') {
124
-                $query->where(['like', 'redirectSrcUrl', $filter]);
125
-                $query->orWhere(['like', 'referrerUrl', $filter]);
124
+                $query->where([ 'like', 'redirectSrcUrl', $filter ]);
125
+                $query->orWhere([ 'like', 'referrerUrl', $filter ]);
126 126
             }
127 127
             $count = $query->count();
128
-            $data['links']['pagination'] = [
128
+            $data[ 'links' ][ 'pagination' ] = [
129 129
                 'total' => $count,
130 130
                 'per_page' => $per_page,
131 131
                 'current_page' => $page,
@@ -160,7 +160,7 @@  discard block
 block discarded – undo
160 160
         $siteId = 0
161 161
     ): Response {
162 162
         PermissionHelper::controllerPermissionCheck('retour:redirects');
163
-        $data = [];
163
+        $data = [ ];
164 164
         $sortField = 'hitCount';
165 165
         $sortType = 'DESC';
166 166
         // Figure out the sorting type
@@ -174,52 +174,52 @@  discard block
 block discarded – undo
174 174
         // Query the db table
175 175
         $offset = ($page - 1) * $per_page;
176 176
         $query = (new Query())
177
-            ->from(['{{%retour_static_redirects}}'])
177
+            ->from([ '{{%retour_static_redirects}}' ])
178 178
             ->offset($offset)
179 179
             ->limit($per_page)
180 180
             ->orderBy("{$sortField} {$sortType}");
181
-        if ((int)$siteId !== 0) {
182
-            $query->where(['siteId' => $siteId]);
181
+        if ((int) $siteId !== 0) {
182
+            $query->where([ 'siteId' => $siteId ]);
183 183
         }
184 184
         if ($filter !== '') {
185
-            $query->where(['like', 'redirectSrcUrl', $filter]);
186
-            $query->orWhere(['like', 'redirectDestUrl', $filter]);
185
+            $query->where([ 'like', 'redirectSrcUrl', $filter ]);
186
+            $query->orWhere([ 'like', 'redirectDestUrl', $filter ]);
187 187
         }
188 188
         $redirects = $query->all();
189 189
         // Add in the `deleteLink` field and clean up the redirects
190 190
         foreach ($redirects as &$redirect) {
191 191
             // Make sure the destination URL is not a regex
192
-            if ($redirect['redirectMatchType'] !== 'exactmatch') {
193
-                if (preg_match("/\$\d+/", $redirect['redirectDestUrl'])) {
194
-                    $redirect['redirectDestUrl'] = '';
192
+            if ($redirect[ 'redirectMatchType' ] !== 'exactmatch') {
193
+                if (preg_match("/\$\d+/", $redirect[ 'redirectDestUrl' ])) {
194
+                    $redirect[ 'redirectDestUrl' ] = '';
195 195
                 }
196 196
             }
197 197
             // Handle extracting the site name
198
-            $redirect['siteName'] = Craft::t('retour', 'All Sites');
199
-            if ($redirect['siteId']) {
198
+            $redirect[ 'siteName' ] = Craft::t('retour', 'All Sites');
199
+            if ($redirect[ 'siteId' ]) {
200 200
                 $sites = Craft::$app->getSites();
201
-                $site = $sites->getSiteById($redirect['siteId']);
201
+                $site = $sites->getSiteById($redirect[ 'siteId' ]);
202 202
                 if ($site) {
203
-                    $redirect['siteName'] = $site->name;
203
+                    $redirect[ 'siteName' ] = $site->name;
204 204
                 }
205 205
             }
206 206
 
207
-            $redirect['editLink'] = UrlHelper::cpUrl('retour/edit-redirect/'.$redirect['id']);
207
+            $redirect[ 'editLink' ] = UrlHelper::cpUrl('retour/edit-redirect/' . $redirect[ 'id' ]);
208 208
         }
209 209
         // Format the data for the API
210 210
         if ($redirects) {
211
-            $data['data'] = $redirects;
211
+            $data[ 'data' ] = $redirects;
212 212
             $query = (new Query())
213
-                ->from(['{{%retour_static_redirects}}']);
214
-            if ((int)$siteId !== 0) {
215
-                $query->where(['siteId' => $siteId]);
213
+                ->from([ '{{%retour_static_redirects}}' ]);
214
+            if ((int) $siteId !== 0) {
215
+                $query->where([ 'siteId' => $siteId ]);
216 216
             }
217 217
             if ($filter !== '') {
218
-                $query->where(['like', 'redirectSrcUrl', $filter]);
219
-                $query->orWhere(['like', 'redirectDestUrl', $filter]);
218
+                $query->where([ 'like', 'redirectSrcUrl', $filter ]);
219
+                $query->orWhere([ 'like', 'redirectDestUrl', $filter ]);
220 220
             }
221 221
             $count = $query->count();
222
-            $data['links']['pagination'] = [
222
+            $data[ 'links' ][ 'pagination' ] = [
223 223
                 'total' => $count,
224 224
                 'per_page' => $per_page,
225 225
                 'current_page' => $page,
Please login to merge, or discard this patch.