@@ -206,7 +206,7 @@  | 
                                                    ||
| 206 | 206 | ->orderBy([$sortField => $sortType])  | 
                                                        
| 207 | 207 | ->filterWhere(['like', 'redirectSrcUrl', $filter])  | 
                                                        
| 208 | 208 | ->orFilterWhere(['like', 'redirectDestUrl', $filter])  | 
                                                        
| 209 | - ;  | 
                                                        |
| 209 | + ;  | 
                                                        |
| 210 | 210 |          if ((int)$siteId !== 0) { | 
                                                        
| 211 | 211 | $query->andWhere(['siteId' => $siteId]);  | 
                                                        
| 212 | 212 | }  | 
                                                        
@@ -96,7 +96,7 @@ discard block  | 
                                                    ||
| 96 | 96 | $handled = 'all'  | 
                                                        
| 97 | 97 |      ): Response { | 
                                                        
| 98 | 98 |          PermissionHelper::controllerPermissionCheck('retour:dashboard'); | 
                                                        
| 99 | - $data = [];  | 
                                                        |
| 99 | + $data = [ ];  | 
                                                        |
| 100 | 100 | $sortField = 'hitCount';  | 
                                                        
| 101 | 101 | $sortType = 'DESC';  | 
                                                        
| 102 | 102 | // Figure out the sorting type  | 
                                                        
@@ -108,7 +108,7 @@ discard block  | 
                                                    ||
| 108 | 108 | }  | 
                                                        
| 109 | 109 | }  | 
                                                        
| 110 | 110 | $sortType = strtoupper($sortType);  | 
                                                        
| 111 | - $sortType = self::SORT_MAP[$sortType] ?? self::SORT_MAP['DESC'];  | 
                                                        |
| 111 | + $sortType = self::SORT_MAP[ $sortType ] ?? self::SORT_MAP[ 'DESC' ];  | 
                                                        |
| 112 | 112 | // Validate untrusted data  | 
                                                        
| 113 | 113 |          if (!in_array($sortField, self::ALLOWED_STATS_SORT_FIELDS, true)) { | 
                                                        
| 114 | 114 |              throw new BadRequestHttpException(Craft::t('retour', 'Invalid sort field specified.')); | 
                                                        
@@ -116,35 +116,35 @@ discard block  | 
                                                    ||
| 116 | 116 | // Query the db table  | 
                                                        
| 117 | 117 | $offset = ($page - 1) * $per_page;  | 
                                                        
| 118 | 118 | $query = (new Query())  | 
                                                        
| 119 | -            ->from(['{{%retour_stats}}']) | 
                                                        |
| 119 | +            ->from([ '{{%retour_stats}}' ]) | 
                                                        |
| 120 | 120 | ->offset($offset)  | 
                                                        
| 121 | 121 | ->limit($per_page)  | 
                                                        
| 122 | - ->orderBy([$sortField => $sortType])  | 
                                                        |
| 123 | - ->filterWhere(['like', 'redirectSrcUrl', $filter])  | 
                                                        |
| 124 | - ->orFilterWhere(['like', 'referrerUrl', $filter])  | 
                                                        |
| 122 | + ->orderBy([ $sortField => $sortType ])  | 
                                                        |
| 123 | + ->filterWhere([ 'like', 'redirectSrcUrl', $filter ])  | 
                                                        |
| 124 | + ->orFilterWhere([ 'like', 'referrerUrl', $filter ])  | 
                                                        |
| 125 | 125 | ;  | 
                                                        
| 126 | -        if ((int)$siteId !== 0) { | 
                                                        |
| 127 | - $query->andWhere(['siteId' => $siteId]);  | 
                                                        |
| 126 | +        if ((int) $siteId !== 0) { | 
                                                        |
| 127 | + $query->andWhere([ 'siteId' => $siteId ]);  | 
                                                        |
| 128 | 128 | }  | 
                                                        
| 129 | 129 |          if ($handled !== 'all') { | 
                                                        
| 130 | - $query->andWhere(['handledByRetour' => self::HANDLED_MAP[$handled]]);  | 
                                                        |
| 130 | + $query->andWhere([ 'handledByRetour' => self::HANDLED_MAP[ $handled ] ]);  | 
                                                        |
| 131 | 131 | }  | 
                                                        
| 132 | 132 | $stats = $query->all();  | 
                                                        
| 133 | 133 |          if ($stats) { | 
                                                        
| 134 | 134 | // Add in the `addLink` field  | 
                                                        
| 135 | 135 |              foreach ($stats as &$stat) { | 
                                                        
| 136 | - $stat['addLink'] = '';  | 
                                                        |
| 137 | -                if (!$stat['handledByRetour']) { | 
                                                        |
| 138 | -                    $encodedUrl = urlencode('/'.ltrim($stat['redirectSrcUrl'], '/')); | 
                                                        |
| 139 | -                    $stat['addLink'] = UrlHelper::cpUrl('retour/add-redirect', [ | 
                                                        |
| 136 | + $stat[ 'addLink' ] = '';  | 
                                                        |
| 137 | +                if (!$stat[ 'handledByRetour' ]) { | 
                                                        |
| 138 | +                    $encodedUrl = urlencode('/' . ltrim($stat[ 'redirectSrcUrl' ], '/')); | 
                                                        |
| 139 | +                    $stat[ 'addLink' ] = UrlHelper::cpUrl('retour/add-redirect', [ | 
                                                        |
| 140 | 140 | 'defaultUrl' => $encodedUrl  | 
                                                        
| 141 | 141 | ]);  | 
                                                        
| 142 | 142 | }  | 
                                                        
| 143 | 143 | }  | 
                                                        
| 144 | 144 | // Format the data for the API  | 
                                                        
| 145 | - $data['data'] = $stats;  | 
                                                        |
| 145 | + $data[ 'data' ] = $stats;  | 
                                                        |
| 146 | 146 | $count = $query->count();  | 
                                                        
| 147 | - $data['links']['pagination'] = [  | 
                                                        |
| 147 | + $data[ 'links' ][ 'pagination' ] = [  | 
                                                        |
| 148 | 148 | 'total' => $count,  | 
                                                        
| 149 | 149 | 'per_page' => $per_page,  | 
                                                        
| 150 | 150 | 'current_page' => $page,  | 
                                                        
@@ -180,7 +180,7 @@ discard block  | 
                                                    ||
| 180 | 180 | $siteId = 0  | 
                                                        
| 181 | 181 |      ): Response { | 
                                                        
| 182 | 182 |          PermissionHelper::controllerPermissionCheck('retour:redirects'); | 
                                                        
| 183 | - $data = [];  | 
                                                        |
| 183 | + $data = [ ];  | 
                                                        |
| 184 | 184 | $sortField = 'hitCount';  | 
                                                        
| 185 | 185 | $sortType = 'DESC';  | 
                                                        
| 186 | 186 | // Figure out the sorting type  | 
                                                        
@@ -192,7 +192,7 @@ discard block  | 
                                                    ||
| 192 | 192 | }  | 
                                                        
| 193 | 193 | }  | 
                                                        
| 194 | 194 | $sortType = strtoupper($sortType);  | 
                                                        
| 195 | - $sortType = self::SORT_MAP[$sortType] ?? self::SORT_MAP['DESC'];  | 
                                                        |
| 195 | + $sortType = self::SORT_MAP[ $sortType ] ?? self::SORT_MAP[ 'DESC' ];  | 
                                                        |
| 196 | 196 | // Validate untrusted data  | 
                                                        
| 197 | 197 |          if (!in_array($sortField, self::ALLOWED_REDIRECTS_SORT_FIELDS, true)) { | 
                                                        
| 198 | 198 |              throw new BadRequestHttpException(Craft::t('retour', 'Invalid sort field specified.')); | 
                                                        
@@ -200,42 +200,42 @@ discard block  | 
                                                    ||
| 200 | 200 | // Query the db table  | 
                                                        
| 201 | 201 | $offset = ($page - 1) * $per_page;  | 
                                                        
| 202 | 202 | $query = (new Query())  | 
                                                        
| 203 | -            ->from(['{{%retour_static_redirects}}']) | 
                                                        |
| 203 | +            ->from([ '{{%retour_static_redirects}}' ]) | 
                                                        |
| 204 | 204 | ->offset($offset)  | 
                                                        
| 205 | 205 | ->limit($per_page)  | 
                                                        
| 206 | - ->orderBy([$sortField => $sortType])  | 
                                                        |
| 207 | - ->filterWhere(['like', 'redirectSrcUrl', $filter])  | 
                                                        |
| 208 | - ->orFilterWhere(['like', 'redirectDestUrl', $filter])  | 
                                                        |
| 206 | + ->orderBy([ $sortField => $sortType ])  | 
                                                        |
| 207 | + ->filterWhere([ 'like', 'redirectSrcUrl', $filter ])  | 
                                                        |
| 208 | + ->orFilterWhere([ 'like', 'redirectDestUrl', $filter ])  | 
                                                        |
| 209 | 209 | ;  | 
                                                        
| 210 | -        if ((int)$siteId !== 0) { | 
                                                        |
| 211 | - $query->andWhere(['siteId' => $siteId]);  | 
                                                        |
| 210 | +        if ((int) $siteId !== 0) { | 
                                                        |
| 211 | + $query->andWhere([ 'siteId' => $siteId ]);  | 
                                                        |
| 212 | 212 | }  | 
                                                        
| 213 | 213 | $redirects = $query->all();  | 
                                                        
| 214 | 214 | // Add in the `deleteLink` field and clean up the redirects  | 
                                                        
| 215 | 215 |          foreach ($redirects as &$redirect) { | 
                                                        
| 216 | 216 | // Make sure the destination URL is not a regex  | 
                                                        
| 217 | -            if ($redirect['redirectMatchType'] !== 'exactmatch') { | 
                                                        |
| 218 | -                if (preg_match("/\$\d+/", $redirect['redirectDestUrl'])) { | 
                                                        |
| 219 | - $redirect['redirectDestUrl'] = '';  | 
                                                        |
| 217 | +            if ($redirect[ 'redirectMatchType' ] !== 'exactmatch') { | 
                                                        |
| 218 | +                if (preg_match("/\$\d+/", $redirect[ 'redirectDestUrl' ])) { | 
                                                        |
| 219 | + $redirect[ 'redirectDestUrl' ] = '';  | 
                                                        |
| 220 | 220 | }  | 
                                                        
| 221 | 221 | }  | 
                                                        
| 222 | 222 | // Handle extracting the site name  | 
                                                        
| 223 | -            $redirect['siteName'] = Craft::t('retour', 'All Sites'); | 
                                                        |
| 224 | -            if ($redirect['siteId']) { | 
                                                        |
| 223 | +            $redirect[ 'siteName' ] = Craft::t('retour', 'All Sites'); | 
                                                        |
| 224 | +            if ($redirect[ 'siteId' ]) { | 
                                                        |
| 225 | 225 | $sites = Craft::$app->getSites();  | 
                                                        
| 226 | - $site = $sites->getSiteById($redirect['siteId']);  | 
                                                        |
| 226 | + $site = $sites->getSiteById($redirect[ 'siteId' ]);  | 
                                                        |
| 227 | 227 |                  if ($site) { | 
                                                        
| 228 | - $redirect['siteName'] = $site->name;  | 
                                                        |
| 228 | + $redirect[ 'siteName' ] = $site->name;  | 
                                                        |
| 229 | 229 | }  | 
                                                        
| 230 | 230 | }  | 
                                                        
| 231 | 231 | |
| 232 | -            $redirect['editLink'] = UrlHelper::cpUrl('retour/edit-redirect/'.$redirect['id']); | 
                                                        |
| 232 | +            $redirect[ 'editLink' ] = UrlHelper::cpUrl('retour/edit-redirect/' . $redirect[ 'id' ]); | 
                                                        |
| 233 | 233 | }  | 
                                                        
| 234 | 234 | // Format the data for the API  | 
                                                        
| 235 | 235 |          if ($redirects) { | 
                                                        
| 236 | - $data['data'] = $redirects;  | 
                                                        |
| 236 | + $data[ 'data' ] = $redirects;  | 
                                                        |
| 237 | 237 | $count = $query->count();  | 
                                                        
| 238 | - $data['links']['pagination'] = [  | 
                                                        |
| 238 | + $data[ 'links' ][ 'pagination' ] = [  | 
                                                        |
| 239 | 239 | 'total' => $count,  | 
                                                        
| 240 | 240 | 'per_page' => $per_page,  | 
                                                        
| 241 | 241 | 'current_page' => $page,  |