@@ -41,7 +41,7 @@ discard block |
||
| 41 | 41 | // Protected Properties |
| 42 | 42 | // ========================================================================= |
| 43 | 43 | |
| 44 | - protected $allowAnonymous = []; |
|
| 44 | + protected $allowAnonymous = [ ]; |
|
| 45 | 45 | |
| 46 | 46 | // Public Methods |
| 47 | 47 | // ========================================================================= |
@@ -57,7 +57,7 @@ discard block |
||
| 57 | 57 | */ |
| 58 | 58 | public function actionRedirects(string $siteHandle = null): Response |
| 59 | 59 | { |
| 60 | - $variables = []; |
|
| 60 | + $variables = [ ]; |
|
| 61 | 61 | PermissionHelper::controllerPermissionCheck('retour:redirects'); |
| 62 | 62 | // Get the site to edit |
| 63 | 63 | $siteId = MultiSiteHelper::getSiteIdFromHandle($siteHandle); |
@@ -70,20 +70,20 @@ discard block |
||
| 70 | 70 | } catch (InvalidConfigException $e) { |
| 71 | 71 | Craft::error($e->getMessage(), __METHOD__); |
| 72 | 72 | } |
| 73 | - $variables['baseAssetsUrl'] = Craft::$app->assetManager->getPublishedUrl( |
|
| 73 | + $variables[ 'baseAssetsUrl' ] = Craft::$app->assetManager->getPublishedUrl( |
|
| 74 | 74 | '@nystudio107/retour/assetbundles/retour/dist', |
| 75 | 75 | true |
| 76 | 76 | ); |
| 77 | 77 | // Enabled sites |
| 78 | 78 | MultiSiteHelper::setMultiSiteVariables($siteHandle, $siteId, $variables); |
| 79 | - $variables['controllerHandle'] = 'redirects'; |
|
| 79 | + $variables[ 'controllerHandle' ] = 'redirects'; |
|
| 80 | 80 | |
| 81 | 81 | // Basic variables |
| 82 | - $variables['fullPageForm'] = false; |
|
| 83 | - $variables['docsUrl'] = self::DOCUMENTATION_URL; |
|
| 84 | - $variables['pluginName'] = $pluginName; |
|
| 85 | - $variables['title'] = $templateTitle; |
|
| 86 | - $variables['crumbs'] = [ |
|
| 82 | + $variables[ 'fullPageForm' ] = false; |
|
| 83 | + $variables[ 'docsUrl' ] = self::DOCUMENTATION_URL; |
|
| 84 | + $variables[ 'pluginName' ] = $pluginName; |
|
| 85 | + $variables[ 'title' ] = $templateTitle; |
|
| 86 | + $variables[ 'crumbs' ] = [ |
|
| 87 | 87 | [ |
| 88 | 88 | 'label' => $pluginName, |
| 89 | 89 | 'url' => UrlHelper::cpUrl('retour'), |
@@ -93,8 +93,8 @@ discard block |
||
| 93 | 93 | 'url' => UrlHelper::cpUrl('retour/redirects'), |
| 94 | 94 | ], |
| 95 | 95 | ]; |
| 96 | - $variables['docTitle'] = "{$pluginName} - {$templateTitle}"; |
|
| 97 | - $variables['selectedSubnavItem'] = 'redirects'; |
|
| 96 | + $variables[ 'docTitle' ] = "{$pluginName} - {$templateTitle}"; |
|
| 97 | + $variables[ 'selectedSubnavItem' ] = 'redirects'; |
|
| 98 | 98 | |
| 99 | 99 | // Render the template |
| 100 | 100 | return $this->renderTemplate('retour/redirects/index', $variables); |
@@ -118,7 +118,7 @@ discard block |
||
| 118 | 118 | string $siteHandle = null, |
| 119 | 119 | StaticRedirectsModel $redirect = null |
| 120 | 120 | ): Response { |
| 121 | - $variables = []; |
|
| 121 | + $variables = [ ]; |
|
| 122 | 122 | PermissionHelper::controllerPermissionCheck('retour:redirects'); |
| 123 | 123 | // Load in the redirect |
| 124 | 124 | if ($redirectId === 0) { |
@@ -130,12 +130,12 @@ discard block |
||
| 130 | 130 | if ($redirect === null) { |
| 131 | 131 | $redirectConfig = Retour::$plugin->redirects->getRedirectById($redirectId); |
| 132 | 132 | if ($redirectConfig === null) { |
| 133 | - $redirectConfig = []; |
|
| 133 | + $redirectConfig = [ ]; |
|
| 134 | 134 | Craft::error( |
| 135 | 135 | Craft::t( |
| 136 | 136 | 'retour', |
| 137 | 137 | "Couldn't load redirect id {id}", |
| 138 | - ['id' => $redirectId] |
|
| 138 | + [ 'id' => $redirectId ] |
|
| 139 | 139 | ), |
| 140 | 140 | __METHOD__ |
| 141 | 141 | ); |
@@ -154,20 +154,20 @@ discard block |
||
| 154 | 154 | } catch (InvalidConfigException $e) { |
| 155 | 155 | Craft::error($e->getMessage(), __METHOD__); |
| 156 | 156 | } |
| 157 | - $variables['baseAssetsUrl'] = Craft::$app->assetManager->getPublishedUrl( |
|
| 157 | + $variables[ 'baseAssetsUrl' ] = Craft::$app->assetManager->getPublishedUrl( |
|
| 158 | 158 | '@nystudio107/retour/assetbundles/retour/dist', |
| 159 | 159 | true |
| 160 | 160 | ); |
| 161 | 161 | // Sites menu |
| 162 | 162 | MultiSiteHelper::setSitesMenuVariables($variables); |
| 163 | - $variables['controllerHandle'] = 'redirects'; |
|
| 163 | + $variables[ 'controllerHandle' ] = 'redirects'; |
|
| 164 | 164 | |
| 165 | 165 | // Basic variables |
| 166 | - $variables['fullPageForm'] = true; |
|
| 167 | - $variables['docsUrl'] = self::DOCUMENTATION_URL; |
|
| 168 | - $variables['pluginName'] = $pluginName; |
|
| 169 | - $variables['title'] = $templateTitle; |
|
| 170 | - $variables['crumbs'] = [ |
|
| 166 | + $variables[ 'fullPageForm' ] = true; |
|
| 167 | + $variables[ 'docsUrl' ] = self::DOCUMENTATION_URL; |
|
| 168 | + $variables[ 'pluginName' ] = $pluginName; |
|
| 169 | + $variables[ 'title' ] = $templateTitle; |
|
| 170 | + $variables[ 'crumbs' ] = [ |
|
| 171 | 171 | [ |
| 172 | 172 | 'label' => $pluginName, |
| 173 | 173 | 'url' => UrlHelper::cpUrl('retour'), |
@@ -178,12 +178,12 @@ discard block |
||
| 178 | 178 | ], |
| 179 | 179 | [ |
| 180 | 180 | 'label' => $templateTitle, |
| 181 | - 'url' => UrlHelper::cpUrl('retour/edit-redirect/'.$redirectId), |
|
| 181 | + 'url' => UrlHelper::cpUrl('retour/edit-redirect/' . $redirectId), |
|
| 182 | 182 | ], |
| 183 | 183 | ]; |
| 184 | - $variables['docTitle'] = "{$pluginName} - Redirects - {$templateTitle}"; |
|
| 185 | - $variables['selectedSubnavItem'] = 'redirects'; |
|
| 186 | - $variables['redirect'] = $redirect; |
|
| 184 | + $variables[ 'docTitle' ] = "{$pluginName} - Redirects - {$templateTitle}"; |
|
| 185 | + $variables[ 'selectedSubnavItem' ] = 'redirects'; |
|
| 186 | + $variables[ 'redirect' ] = $redirect; |
|
| 187 | 187 | |
| 188 | 188 | // Render the template |
| 189 | 189 | return $this->renderTemplate('retour/redirects/_edit', $variables); |
@@ -229,7 +229,7 @@ discard block |
||
| 229 | 229 | if ($redirectConfig === null) { |
| 230 | 230 | throw new NotFoundHttpException('Redirect not found'); |
| 231 | 231 | } |
| 232 | - $redirectConfig['id'] = (int)$redirectConfig['id']; |
|
| 232 | + $redirectConfig[ 'id' ] = (int) $redirectConfig[ 'id' ]; |
|
| 233 | 233 | $redirect = new StaticRedirectsModel($redirectConfig); |
| 234 | 234 | // Make sure the redirect validates |
| 235 | 235 | if (!$redirect->validate()) { |
@@ -36,7 +36,7 @@ discard block |
||
| 36 | 36 | public static function setSitesMenuVariables(array &$variables) |
| 37 | 37 | { |
| 38 | 38 | // Set defaults based on the section settings |
| 39 | - $variables['sitesMenu'] = [ |
|
| 39 | + $variables[ 'sitesMenu' ] = [ |
|
| 40 | 40 | 0 => Craft::t( |
| 41 | 41 | 'retour', |
| 42 | 42 | 'All Sites' |
@@ -49,10 +49,10 @@ discard block |
||
| 49 | 49 | /** @var Site $site */ |
| 50 | 50 | foreach ($sites->getAllGroups() as $group) { |
| 51 | 51 | $groupSites = $sites->getSitesByGroupId($group->id); |
| 52 | - $variables['sitesMenu'][$group->name] |
|
| 53 | - = ['optgroup' => $group->name]; |
|
| 52 | + $variables[ 'sitesMenu' ][ $group->name ] |
|
| 53 | + = [ 'optgroup' => $group->name ]; |
|
| 54 | 54 | foreach ($groupSites as $groupSite) { |
| 55 | - $variables['sitesMenu'][$groupSite->id] = $groupSite->name; |
|
| 55 | + $variables[ 'sitesMenu' ][ $groupSite->id ] = $groupSite->name; |
|
| 56 | 56 | } |
| 57 | 57 | } |
| 58 | 58 | } |
@@ -71,53 +71,53 @@ discard block |
||
| 71 | 71 | $sites = Craft::$app->getSites(); |
| 72 | 72 | if (Craft::$app->getIsMultiSite()) { |
| 73 | 73 | // Set defaults based on the section settings |
| 74 | - $variables['enabledSiteIds'] = []; |
|
| 75 | - $variables['siteIds'] = []; |
|
| 74 | + $variables[ 'enabledSiteIds' ] = [ ]; |
|
| 75 | + $variables[ 'siteIds' ] = [ ]; |
|
| 76 | 76 | |
| 77 | 77 | /** @var Site $site */ |
| 78 | 78 | foreach ($sites->getEditableSiteIds() as $editableSiteId) { |
| 79 | - $variables['enabledSiteIds'][] = $editableSiteId; |
|
| 80 | - $variables['siteIds'][] = $editableSiteId; |
|
| 79 | + $variables[ 'enabledSiteIds' ][ ] = $editableSiteId; |
|
| 80 | + $variables[ 'siteIds' ][ ] = $editableSiteId; |
|
| 81 | 81 | } |
| 82 | 82 | |
| 83 | 83 | // Make sure the $siteId they are trying to edit is in our array of editable sites |
| 84 | - if (!\in_array($siteId, $variables['enabledSiteIds'], false)) { |
|
| 85 | - if (!empty($variables['enabledSiteIds'])) { |
|
| 84 | + if (!\in_array($siteId, $variables[ 'enabledSiteIds' ], false)) { |
|
| 85 | + if (!empty($variables[ 'enabledSiteIds' ])) { |
|
| 86 | 86 | if ($siteId !== 0) { |
| 87 | - $siteId = reset($variables['enabledSiteIds']); |
|
| 87 | + $siteId = reset($variables[ 'enabledSiteIds' ]); |
|
| 88 | 88 | } |
| 89 | 89 | } else { |
| 90 | - self::requirePermission('editSite:'.$siteId); |
|
| 90 | + self::requirePermission('editSite:' . $siteId); |
|
| 91 | 91 | } |
| 92 | 92 | } |
| 93 | 93 | } |
| 94 | 94 | // Set the currentSiteId and currentSiteHandle |
| 95 | - $variables['currentSiteId'] = empty($siteId) ? 0 : $siteId; |
|
| 96 | - $variables['currentSiteHandle'] = empty($siteHandle) |
|
| 95 | + $variables[ 'currentSiteId' ] = empty($siteId) ? 0 : $siteId; |
|
| 96 | + $variables[ 'currentSiteHandle' ] = empty($siteHandle) |
|
| 97 | 97 | ? Craft::$app->getSites()->currentSite->handle |
| 98 | 98 | : $siteHandle; |
| 99 | 99 | |
| 100 | 100 | // Page title |
| 101 | - $variables['showSites'] = ( |
|
| 101 | + $variables[ 'showSites' ] = ( |
|
| 102 | 102 | Craft::$app->getIsMultiSite() && |
| 103 | - \count($variables['enabledSiteIds']) |
|
| 103 | + \count($variables[ 'enabledSiteIds' ]) |
|
| 104 | 104 | ); |
| 105 | 105 | |
| 106 | - if ($variables['showSites']) { |
|
| 107 | - if ($variables['currentSiteId'] === 0) { |
|
| 108 | - $variables['sitesMenuLabel'] = Craft::t( |
|
| 106 | + if ($variables[ 'showSites' ]) { |
|
| 107 | + if ($variables[ 'currentSiteId' ] === 0) { |
|
| 108 | + $variables[ 'sitesMenuLabel' ] = Craft::t( |
|
| 109 | 109 | 'retour', |
| 110 | 110 | 'All Sites' |
| 111 | 111 | ); |
| 112 | 112 | } else { |
| 113 | - $variables['sitesMenuLabel'] = Craft::t( |
|
| 113 | + $variables[ 'sitesMenuLabel' ] = Craft::t( |
|
| 114 | 114 | 'site', |
| 115 | - $sites->getSiteById((int)$variables['currentSiteId'])->name |
|
| 115 | + $sites->getSiteById((int) $variables[ 'currentSiteId' ])->name |
|
| 116 | 116 | ); |
| 117 | 117 | } |
| 118 | 118 | } else { |
| 119 | - $variables['currentSiteId'] = 0; |
|
| 120 | - $variables['sitesMenuLabel'] = ''; |
|
| 119 | + $variables[ 'currentSiteId' ] = 0; |
|
| 120 | + $variables[ 'sitesMenuLabel' ] = ''; |
|
| 121 | 121 | } |
| 122 | 122 | } |
| 123 | 123 | |
@@ -135,7 +135,7 @@ discard block |
||
| 135 | 135 | if ($siteHandle !== null) { |
| 136 | 136 | $site = Craft::$app->getSites()->getSiteByHandle($siteHandle); |
| 137 | 137 | if (!$site) { |
| 138 | - throw new NotFoundHttpException('Invalid site handle: '.$siteHandle); |
|
| 138 | + throw new NotFoundHttpException('Invalid site handle: ' . $siteHandle); |
|
| 139 | 139 | } |
| 140 | 140 | $siteId = $site->id; |
| 141 | 141 | } else { |
@@ -92,7 +92,7 @@ discard block |
||
| 92 | 92 | Craft::t( |
| 93 | 93 | 'retour', |
| 94 | 94 | '404 full URL: {fullUrl}, 404 path only: {pathOnly}', |
| 95 | - ['fullUrl' => $fullUrl, 'pathOnly' => $pathOnly] |
|
| 95 | + [ 'fullUrl' => $fullUrl, 'pathOnly' => $pathOnly ] |
|
| 96 | 96 | ), |
| 97 | 97 | __METHOD__ |
| 98 | 98 | ); |
@@ -124,7 +124,7 @@ discard block |
||
| 124 | 124 | $response = Craft::$app->getResponse(); |
| 125 | 125 | if ($redirect !== null) { |
| 126 | 126 | // Figure out what type of source matching was done |
| 127 | - $redirectSrcMatch = $redirect['redirectSrcMatch'] ?? 'pathonly'; |
|
| 127 | + $redirectSrcMatch = $redirect[ 'redirectSrcMatch' ] ?? 'pathonly'; |
|
| 128 | 128 | switch ($redirectSrcMatch) { |
| 129 | 129 | case 'pathonly': |
| 130 | 130 | $url = $pathOnly; |
@@ -136,17 +136,17 @@ discard block |
||
| 136 | 136 | $url = $pathOnly; |
| 137 | 137 | break; |
| 138 | 138 | } |
| 139 | - $dest = $redirect['redirectDestUrl']; |
|
| 139 | + $dest = $redirect[ 'redirectDestUrl' ]; |
|
| 140 | 140 | if (Retour::$settings->preserveQueryString) { |
| 141 | 141 | $request = Craft::$app->getRequest(); |
| 142 | 142 | $dest .= '?' . $request->getQueryString(); |
| 143 | 143 | } |
| 144 | - $status = $redirect['redirectHttpCode']; |
|
| 144 | + $status = $redirect[ 'redirectHttpCode' ]; |
|
| 145 | 145 | Craft::info( |
| 146 | 146 | Craft::t( |
| 147 | 147 | 'retour', |
| 148 | 148 | 'Redirecting {url} to {dest} with status {status}', |
| 149 | - ['url' => $url, 'dest' => $dest, 'status' => $status] |
|
| 149 | + [ 'url' => $url, 'dest' => $dest, 'status' => $status ] |
|
| 150 | 150 | ), |
| 151 | 151 | __METHOD__ |
| 152 | 152 | ); |
@@ -221,13 +221,13 @@ discard block |
||
| 221 | 221 | public function getRedirectFromCache($url) |
| 222 | 222 | { |
| 223 | 223 | $cache = Craft::$app->getCache(); |
| 224 | - $cacheKey = $this::CACHE_KEY.md5($url); |
|
| 224 | + $cacheKey = $this::CACHE_KEY . md5($url); |
|
| 225 | 225 | $redirect = $cache->get($cacheKey); |
| 226 | 226 | Craft::info( |
| 227 | 227 | Craft::t( |
| 228 | 228 | 'retour', |
| 229 | 229 | 'Cached redirect hit for {url}', |
| 230 | - ['url' => $url] |
|
| 230 | + [ 'url' => $url ] |
|
| 231 | 231 | ), |
| 232 | 232 | __METHOD__ |
| 233 | 233 | ); |
@@ -241,7 +241,7 @@ discard block |
||
| 241 | 241 | */ |
| 242 | 242 | public function saveRedirectToCache($url, $redirect) |
| 243 | 243 | { |
| 244 | - $cacheKey = $this::CACHE_KEY.md5($url); |
|
| 244 | + $cacheKey = $this::CACHE_KEY . md5($url); |
|
| 245 | 245 | $cache = Craft::$app->getCache(); |
| 246 | 246 | // Get the current site id |
| 247 | 247 | $sites = Craft::$app->getSites(); |
@@ -254,7 +254,7 @@ discard block |
||
| 254 | 254 | $dependency = new TagDependency([ |
| 255 | 255 | 'tags' => [ |
| 256 | 256 | $this::GLOBAL_REDIRECTS_CACHE_TAG, |
| 257 | - $this::GLOBAL_REDIRECTS_CACHE_TAG.$siteId, |
|
| 257 | + $this::GLOBAL_REDIRECTS_CACHE_TAG . $siteId, |
|
| 258 | 258 | ], |
| 259 | 259 | ]); |
| 260 | 260 | $cache->set($cacheKey, $redirect, Retour::$cacheDuration, $dependency); |
@@ -262,7 +262,7 @@ discard block |
||
| 262 | 262 | Craft::t( |
| 263 | 263 | 'retour', |
| 264 | 264 | 'Cached redirect saved for {url}', |
| 265 | - ['url' => $url] |
|
| 265 | + [ 'url' => $url ] |
|
| 266 | 266 | ), |
| 267 | 267 | __METHOD__ |
| 268 | 268 | ); |
@@ -280,8 +280,8 @@ discard block |
||
| 280 | 280 | $result = null; |
| 281 | 281 | foreach ($redirects as $redirect) { |
| 282 | 282 | // Figure out what type of source matching to do |
| 283 | - $redirectSrcMatch = $redirect['redirectSrcMatch'] ?? 'pathonly'; |
|
| 284 | - $redirectEnabled = (bool)$redirect['enabled']; |
|
| 283 | + $redirectSrcMatch = $redirect[ 'redirectSrcMatch' ] ?? 'pathonly'; |
|
| 284 | + $redirectEnabled = (bool) $redirect[ 'enabled' ]; |
|
| 285 | 285 | if ($redirectEnabled === true) { |
| 286 | 286 | switch ($redirectSrcMatch) { |
| 287 | 287 | case 'pathonly': |
@@ -294,11 +294,11 @@ discard block |
||
| 294 | 294 | $url = $pathOnly; |
| 295 | 295 | break; |
| 296 | 296 | } |
| 297 | - $redirectMatchType = $redirect['redirectMatchType'] ?? 'notfound'; |
|
| 297 | + $redirectMatchType = $redirect[ 'redirectMatchType' ] ?? 'notfound'; |
|
| 298 | 298 | switch ($redirectMatchType) { |
| 299 | 299 | // Do a straight up match |
| 300 | 300 | case 'exactmatch': |
| 301 | - if (strcasecmp($redirect['redirectSrcUrlParsed'], $url) === 0) { |
|
| 301 | + if (strcasecmp($redirect[ 'redirectSrcUrlParsed' ], $url) === 0) { |
|
| 302 | 302 | $this->incrementRedirectHitCount($redirect); |
| 303 | 303 | $this->saveRedirectToCache($url, $redirect); |
| 304 | 304 | |
@@ -308,14 +308,14 @@ discard block |
||
| 308 | 308 | |
| 309 | 309 | // Do a regex match |
| 310 | 310 | case 'regexmatch': |
| 311 | - $matchRegEx = '`'.$redirect['redirectSrcUrlParsed'].'`i'; |
|
| 311 | + $matchRegEx = '`' . $redirect[ 'redirectSrcUrlParsed' ] . '`i'; |
|
| 312 | 312 | if (preg_match($matchRegEx, $url) === 1) { |
| 313 | 313 | $this->incrementRedirectHitCount($redirect); |
| 314 | 314 | // If we're not associated with an EntryID, handle capture group replacement |
| 315 | - if ((int)$redirect['associatedElementId'] === 0) { |
|
| 316 | - $redirect['redirectDestUrl'] = preg_replace( |
|
| 315 | + if ((int) $redirect[ 'associatedElementId' ] === 0) { |
|
| 316 | + $redirect[ 'redirectDestUrl' ] = preg_replace( |
|
| 317 | 317 | $matchRegEx, |
| 318 | - $redirect['redirectDestUrl'], |
|
| 318 | + $redirect[ 'redirectDestUrl' ], |
|
| 319 | 319 | $url |
| 320 | 320 | ); |
| 321 | 321 | } |
@@ -334,7 +334,7 @@ discard block |
||
| 334 | 334 | 'redirect' => &$redirect, |
| 335 | 335 | ], |
| 336 | 336 | ]; |
| 337 | - $result = \call_user_func_array([$plugin, 'retourMatch'], $args); |
|
| 337 | + $result = \call_user_func_array([ $plugin, 'retourMatch' ], $args); |
|
| 338 | 338 | if ($result) { |
| 339 | 339 | $this->incrementRedirectHitCount($redirect); |
| 340 | 340 | $this->saveRedirectToCache($url, $redirect); |
@@ -350,7 +350,7 @@ discard block |
||
| 350 | 350 | Craft::t( |
| 351 | 351 | 'retour', |
| 352 | 352 | 'Not handled-> full URL: {fullUrl}, path only: {pathOnly}', |
| 353 | - ['fullUrl' => $fullUrl, 'pathOnly' => $pathOnly] |
|
| 353 | + [ 'fullUrl' => $fullUrl, 'pathOnly' => $pathOnly ] |
|
| 354 | 354 | ), |
| 355 | 355 | __METHOD__ |
| 356 | 356 | ); |
@@ -374,7 +374,7 @@ discard block |
||
| 374 | 374 | foreach (Craft::$app->getPlugins()->getAllPlugins() as $plugin) { |
| 375 | 375 | /** @var Plugin $plugin */ |
| 376 | 376 | if (method_exists($plugin, 'retourMatch')) { |
| 377 | - $result[$plugin->getHandle()] = $plugin->name.Craft::t('retour', ' Match'); |
|
| 377 | + $result[ $plugin->getHandle() ] = $plugin->name . Craft::t('retour', ' Match'); |
|
| 378 | 378 | } |
| 379 | 379 | } |
| 380 | 380 | |
@@ -394,7 +394,7 @@ discard block |
||
| 394 | 394 | } |
| 395 | 395 | // Query the db table |
| 396 | 396 | $query = (new Query()) |
| 397 | - ->from(['{{%retour_static_redirects}}']) |
|
| 397 | + ->from([ '{{%retour_static_redirects}}' ]) |
|
| 398 | 398 | ->orderBy('redirectMatchType ASC, redirectSrcMatch ASC, hitCount DESC'); |
| 399 | 399 | if ($limit) { |
| 400 | 400 | $query->limit($limit); |
@@ -417,8 +417,8 @@ discard block |
||
| 417 | 417 | { |
| 418 | 418 | // Query the db table |
| 419 | 419 | $redirect = (new Query()) |
| 420 | - ->from(['{{%retour_static_redirects}}']) |
|
| 421 | - ->where(['id' => $id]) |
|
| 420 | + ->from([ '{{%retour_static_redirects}}' ]) |
|
| 421 | + ->where([ 'id' => $id ]) |
|
| 422 | 422 | ->one(); |
| 423 | 423 | |
| 424 | 424 | return $redirect; |
@@ -435,8 +435,8 @@ discard block |
||
| 435 | 435 | { |
| 436 | 436 | // Query the db table |
| 437 | 437 | $redirect = (new Query()) |
| 438 | - ->from(['{{%retour_static_redirects}}']) |
|
| 439 | - ->where(['redirectSrcUrl' => $redirectSrcUrl]) |
|
| 438 | + ->from([ '{{%retour_static_redirects}}' ]) |
|
| 439 | + ->where([ 'redirectSrcUrl' => $redirectSrcUrl ]) |
|
| 440 | 440 | ->one(); |
| 441 | 441 | |
| 442 | 442 | return $redirect; |
@@ -477,13 +477,13 @@ discard block |
||
| 477 | 477 | { |
| 478 | 478 | if ($redirectConfig !== null) { |
| 479 | 479 | $db = Craft::$app->getDb(); |
| 480 | - $redirectConfig['hitCount']++; |
|
| 481 | - $redirectConfig['hitLastTime'] = Db::prepareDateForDb(new \DateTime()); |
|
| 480 | + $redirectConfig[ 'hitCount' ]++; |
|
| 481 | + $redirectConfig[ 'hitLastTime' ] = Db::prepareDateForDb(new \DateTime()); |
|
| 482 | 482 | Craft::debug( |
| 483 | 483 | Craft::t( |
| 484 | 484 | 'retour', |
| 485 | 485 | 'Incrementing statistics for: {redirect}', |
| 486 | - ['redirect' => print_r($redirectConfig, true)] |
|
| 486 | + [ 'redirect' => print_r($redirectConfig, true) ] |
|
| 487 | 487 | ), |
| 488 | 488 | __METHOD__ |
| 489 | 489 | ); |
@@ -492,14 +492,14 @@ discard block |
||
| 492 | 492 | $rowsAffected = $db->createCommand()->update( |
| 493 | 493 | '{{%retour_static_redirects}}', |
| 494 | 494 | [ |
| 495 | - 'hitCount' => $redirectConfig['hitCount'], |
|
| 496 | - 'hitLastTime' => $redirectConfig['hitLastTime'], |
|
| 495 | + 'hitCount' => $redirectConfig[ 'hitCount' ], |
|
| 496 | + 'hitLastTime' => $redirectConfig[ 'hitLastTime' ], |
|
| 497 | 497 | ], |
| 498 | 498 | [ |
| 499 | - 'id' => $redirectConfig['id'], |
|
| 499 | + 'id' => $redirectConfig[ 'id' ], |
|
| 500 | 500 | ] |
| 501 | 501 | )->execute(); |
| 502 | - Craft::debug('Rows affected: '.$rowsAffected, __METHOD__); |
|
| 502 | + Craft::debug('Rows affected: ' . $rowsAffected, __METHOD__); |
|
| 503 | 503 | } catch (Exception $e) { |
| 504 | 504 | Craft::error($e->getMessage(), __METHOD__); |
| 505 | 505 | } |
@@ -518,7 +518,7 @@ discard block |
||
| 518 | 518 | Craft::t( |
| 519 | 519 | 'retour', |
| 520 | 520 | 'Error validating redirect {id}: {errors}', |
| 521 | - ['id' => $redirect->id, 'errors' => print_r($redirect->getErrors(), true)] |
|
| 521 | + [ 'id' => $redirect->id, 'errors' => print_r($redirect->getErrors(), true) ] |
|
| 522 | 522 | ), |
| 523 | 523 | __METHOD__ |
| 524 | 524 | ); |
@@ -528,28 +528,28 @@ discard block |
||
| 528 | 528 | // Get the validated model attributes and save them to the db |
| 529 | 529 | $redirectConfig = $redirect->getAttributes(); |
| 530 | 530 | // 0 for a siteId needs to be converted to null |
| 531 | - if (empty($redirectConfig['siteId']) || $redirectConfig['siteId'] == 0) { |
|
| 532 | - $redirectConfig['siteId'] = null; |
|
| 531 | + if (empty($redirectConfig[ 'siteId' ]) || $redirectConfig[ 'siteId' ] == 0) { |
|
| 532 | + $redirectConfig[ 'siteId' ] = null; |
|
| 533 | 533 | } |
| 534 | 534 | $db = Craft::$app->getDb(); |
| 535 | 535 | // See if a redirect exists with this source URL already |
| 536 | - if ((int)$redirectConfig['id'] === 0) { |
|
| 536 | + if ((int) $redirectConfig[ 'id' ] === 0) { |
|
| 537 | 537 | // Query the db table |
| 538 | 538 | $redirect = (new Query()) |
| 539 | - ->from(['{{%retour_static_redirects}}']) |
|
| 540 | - ->where(['redirectSrcUrlParsed' => $redirectConfig['redirectSrcUrlParsed']]) |
|
| 539 | + ->from([ '{{%retour_static_redirects}}' ]) |
|
| 540 | + ->where([ 'redirectSrcUrlParsed' => $redirectConfig[ 'redirectSrcUrlParsed' ] ]) |
|
| 541 | 541 | ->one(); |
| 542 | 542 | // If it exists, update it rather than having duplicates |
| 543 | 543 | if (!empty($redirect)) { |
| 544 | - $redirectConfig['id'] = $redirect['id']; |
|
| 544 | + $redirectConfig[ 'id' ] = $redirect[ 'id' ]; |
|
| 545 | 545 | } |
| 546 | 546 | } |
| 547 | - if ((int)$redirectConfig['id'] !== 0) { |
|
| 547 | + if ((int) $redirectConfig[ 'id' ] !== 0) { |
|
| 548 | 548 | Craft::debug( |
| 549 | 549 | Craft::t( |
| 550 | 550 | 'retour', |
| 551 | 551 | 'Updating existing redirect: {redirect}', |
| 552 | - ['redirect' => print_r($redirectConfig, true)] |
|
| 552 | + [ 'redirect' => print_r($redirectConfig, true) ] |
|
| 553 | 553 | ), |
| 554 | 554 | __METHOD__ |
| 555 | 555 | ); |
@@ -559,7 +559,7 @@ discard block |
||
| 559 | 559 | '{{%retour_static_redirects}}', |
| 560 | 560 | $redirectConfig, |
| 561 | 561 | [ |
| 562 | - 'id' => $redirectConfig['id'], |
|
| 562 | + 'id' => $redirectConfig[ 'id' ], |
|
| 563 | 563 | ] |
| 564 | 564 | )->execute(); |
| 565 | 565 | } catch (Exception $e) { |
@@ -570,11 +570,11 @@ discard block |
||
| 570 | 570 | Craft::t( |
| 571 | 571 | 'retour', |
| 572 | 572 | 'Creating new redirect: {redirect}', |
| 573 | - ['redirect' => print_r($redirectConfig, true)] |
|
| 573 | + [ 'redirect' => print_r($redirectConfig, true) ] |
|
| 574 | 574 | ), |
| 575 | 575 | __METHOD__ |
| 576 | 576 | ); |
| 577 | - unset($redirectConfig['id']); |
|
| 577 | + unset($redirectConfig[ 'id' ]); |
|
| 578 | 578 | // Create a new record |
| 579 | 579 | try { |
| 580 | 580 | $db->createCommand()->insert( |
@@ -586,13 +586,13 @@ discard block |
||
| 586 | 586 | } |
| 587 | 587 | } |
| 588 | 588 | // To prevent redirect loops, see if any static redirects have our redirectDestUrl as their redirectSrcUrl |
| 589 | - $testRedirectConfig = $this->getRedirectByRedirectSrcUrl($redirectConfig['redirectDestUrl']); |
|
| 589 | + $testRedirectConfig = $this->getRedirectByRedirectSrcUrl($redirectConfig[ 'redirectDestUrl' ]); |
|
| 590 | 590 | if ($testRedirectConfig !== null) { |
| 591 | 591 | Craft::debug( |
| 592 | 592 | Craft::t( |
| 593 | 593 | 'retour', |
| 594 | 594 | 'Deleting redirect to prevent a loop: {redirect}', |
| 595 | - ['redirect' => print_r($testRedirectConfig, true)] |
|
| 595 | + [ 'redirect' => print_r($testRedirectConfig, true) ] |
|
| 596 | 596 | ), |
| 597 | 597 | __METHOD__ |
| 598 | 598 | ); |
@@ -600,7 +600,7 @@ discard block |
||
| 600 | 600 | try { |
| 601 | 601 | $db->createCommand()->delete( |
| 602 | 602 | '{{%retour_static_redirects}}', |
| 603 | - ['id' => $testRedirectConfig['id']] |
|
| 603 | + [ 'id' => $testRedirectConfig[ 'id' ] ] |
|
| 604 | 604 | )->execute(); |
| 605 | 605 | } catch (Exception $e) { |
| 606 | 606 | Craft::error($e->getMessage(), __METHOD__); |