@@ -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,32 +70,32 @@ 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 | - $siteHandleUri = Craft::$app->isMultiSite ? '/'.$siteHandle : ''; |
|
| 87 | - $variables['crumbs'] = [ |
|
| 82 | + $variables[ 'fullPageForm' ] = false; |
|
| 83 | + $variables[ 'docsUrl' ] = self::DOCUMENTATION_URL; |
|
| 84 | + $variables[ 'pluginName' ] = $pluginName; |
|
| 85 | + $variables[ 'title' ] = $templateTitle; |
|
| 86 | + $siteHandleUri = Craft::$app->isMultiSite ? '/' . $siteHandle : ''; |
|
| 87 | + $variables[ 'crumbs' ] = [ |
|
| 88 | 88 | [ |
| 89 | 89 | 'label' => $pluginName, |
| 90 | 90 | 'url' => UrlHelper::cpUrl('retour'), |
| 91 | 91 | ], |
| 92 | 92 | [ |
| 93 | 93 | 'label' => $templateTitle, |
| 94 | - 'url' => UrlHelper::cpUrl('retour/redirects'.$siteHandleUri), |
|
| 94 | + 'url' => UrlHelper::cpUrl('retour/redirects' . $siteHandleUri), |
|
| 95 | 95 | ], |
| 96 | 96 | ]; |
| 97 | - $variables['docTitle'] = "{$pluginName} - {$templateTitle}"; |
|
| 98 | - $variables['selectedSubnavItem'] = 'redirects'; |
|
| 97 | + $variables[ 'docTitle' ] = "{$pluginName} - {$templateTitle}"; |
|
| 98 | + $variables[ 'selectedSubnavItem' ] = 'redirects'; |
|
| 99 | 99 | |
| 100 | 100 | // Render the template |
| 101 | 101 | return $this->renderTemplate('retour/redirects/index', $variables); |
@@ -119,7 +119,7 @@ discard block |
||
| 119 | 119 | int $siteId = 0, |
| 120 | 120 | StaticRedirectsModel $redirect = null |
| 121 | 121 | ): Response { |
| 122 | - $variables = []; |
|
| 122 | + $variables = [ ]; |
|
| 123 | 123 | PermissionHelper::controllerPermissionCheck('retour:redirects'); |
| 124 | 124 | |
| 125 | 125 | // Load in the redirect |
@@ -133,12 +133,12 @@ discard block |
||
| 133 | 133 | if ($redirect === null) { |
| 134 | 134 | $redirectConfig = Retour::$plugin->redirects->getRedirectById($redirectId); |
| 135 | 135 | if ($redirectConfig === null) { |
| 136 | - $redirectConfig = []; |
|
| 136 | + $redirectConfig = [ ]; |
|
| 137 | 137 | Craft::error( |
| 138 | 138 | Craft::t( |
| 139 | 139 | 'retour', |
| 140 | 140 | "Couldn't load redirect id {id}", |
| 141 | - ['id' => $redirectId] |
|
| 141 | + [ 'id' => $redirectId ] |
|
| 142 | 142 | ), |
| 143 | 143 | __METHOD__ |
| 144 | 144 | ); |
@@ -151,13 +151,13 @@ discard block |
||
| 151 | 151 | if ($redirect->siteId) { |
| 152 | 152 | $site = $sites->getSiteById($redirect->siteId); |
| 153 | 153 | if ($site) { |
| 154 | - MultiSiteHelper::requirePermission('editSite:'.$site->uid); |
|
| 154 | + MultiSiteHelper::requirePermission('editSite:' . $site->uid); |
|
| 155 | 155 | } |
| 156 | 156 | } |
| 157 | 157 | if ($siteId) { |
| 158 | 158 | $site = $sites->getSiteById($siteId); |
| 159 | 159 | if ($site) { |
| 160 | - MultiSiteHelper::requirePermission('editSite:'.$site->uid); |
|
| 160 | + MultiSiteHelper::requirePermission('editSite:' . $site->uid); |
|
| 161 | 161 | } |
| 162 | 162 | } |
| 163 | 163 | $pluginName = Retour::$settings->pluginName; |
@@ -169,20 +169,20 @@ discard block |
||
| 169 | 169 | } catch (InvalidConfigException $e) { |
| 170 | 170 | Craft::error($e->getMessage(), __METHOD__); |
| 171 | 171 | } |
| 172 | - $variables['baseAssetsUrl'] = Craft::$app->assetManager->getPublishedUrl( |
|
| 172 | + $variables[ 'baseAssetsUrl' ] = Craft::$app->assetManager->getPublishedUrl( |
|
| 173 | 173 | '@nystudio107/retour/assetbundles/retour/dist', |
| 174 | 174 | true |
| 175 | 175 | ); |
| 176 | 176 | // Sites menu |
| 177 | 177 | MultiSiteHelper::setSitesMenuVariables($variables); |
| 178 | - $variables['controllerHandle'] = 'redirects'; |
|
| 178 | + $variables[ 'controllerHandle' ] = 'redirects'; |
|
| 179 | 179 | |
| 180 | 180 | // Basic variables |
| 181 | - $variables['fullPageForm'] = true; |
|
| 182 | - $variables['docsUrl'] = self::DOCUMENTATION_URL; |
|
| 183 | - $variables['pluginName'] = $pluginName; |
|
| 184 | - $variables['title'] = $templateTitle; |
|
| 185 | - $variables['crumbs'] = [ |
|
| 181 | + $variables[ 'fullPageForm' ] = true; |
|
| 182 | + $variables[ 'docsUrl' ] = self::DOCUMENTATION_URL; |
|
| 183 | + $variables[ 'pluginName' ] = $pluginName; |
|
| 184 | + $variables[ 'title' ] = $templateTitle; |
|
| 185 | + $variables[ 'crumbs' ] = [ |
|
| 186 | 186 | [ |
| 187 | 187 | 'label' => $pluginName, |
| 188 | 188 | 'url' => UrlHelper::cpUrl('retour'), |
@@ -193,12 +193,12 @@ discard block |
||
| 193 | 193 | ], |
| 194 | 194 | [ |
| 195 | 195 | 'label' => $templateTitle, |
| 196 | - 'url' => UrlHelper::cpUrl('retour/edit-redirect/'.$redirectId), |
|
| 196 | + 'url' => UrlHelper::cpUrl('retour/edit-redirect/' . $redirectId), |
|
| 197 | 197 | ], |
| 198 | 198 | ]; |
| 199 | - $variables['docTitle'] = "{$pluginName} - Redirects - {$templateTitle}"; |
|
| 200 | - $variables['selectedSubnavItem'] = 'redirects'; |
|
| 201 | - $variables['redirect'] = $redirect; |
|
| 199 | + $variables[ 'docTitle' ] = "{$pluginName} - Redirects - {$templateTitle}"; |
|
| 200 | + $variables[ 'selectedSubnavItem' ] = 'redirects'; |
|
| 201 | + $variables[ 'redirect' ] = $redirect; |
|
| 202 | 202 | |
| 203 | 203 | // Render the template |
| 204 | 204 | return $this->renderTemplate('retour/redirects/_edit', $variables); |
@@ -251,12 +251,12 @@ discard block |
||
| 251 | 251 | if ($redirectConfig === null) { |
| 252 | 252 | throw new NotFoundHttpException('Redirect not found'); |
| 253 | 253 | } |
| 254 | - $redirectConfig['id'] = (int)$redirectConfig['id']; |
|
| 254 | + $redirectConfig[ 'id' ] = (int) $redirectConfig[ 'id' ]; |
|
| 255 | 255 | // Handle enforcing trailing slashes |
| 256 | 256 | $generalConfig = Craft::$app->getConfig()->getGeneral(); |
| 257 | 257 | if ($generalConfig->addTrailingSlashesToUrls) { |
| 258 | - $destUrl = $redirectConfig['redirectDestUrl'] ?? ''; |
|
| 259 | - $redirectConfig['redirectDestUrl'] = $this->addSlashToSiteUrls($destUrl); |
|
| 258 | + $destUrl = $redirectConfig[ 'redirectDestUrl' ] ?? ''; |
|
| 259 | + $redirectConfig[ 'redirectDestUrl' ] = $this->addSlashToSiteUrls($destUrl); |
|
| 260 | 260 | } |
| 261 | 261 | $redirect = new StaticRedirectsModel($redirectConfig); |
| 262 | 262 | // Make sure the redirect validates |
@@ -274,8 +274,8 @@ discard block |
||
| 274 | 274 | Retour::$plugin->redirects->saveRedirect($redirectConfig); |
| 275 | 275 | // Handle the case where the redirect wasn't saved because it'd create a redirect loop |
| 276 | 276 | $testRedirectConfig = Retour::$plugin->redirects->getRedirectByRedirectSrcUrl( |
| 277 | - $redirectConfig['redirectSrcUrl'], |
|
| 278 | - $redirectConfig['siteId'] |
|
| 277 | + $redirectConfig[ 'redirectSrcUrl' ], |
|
| 278 | + $redirectConfig[ 'siteId' ] |
|
| 279 | 279 | ); |
| 280 | 280 | if ($testRedirectConfig === null) { |
| 281 | 281 | Craft::$app->getSession()->setError(Craft::t('app', "Couldn't save redirect settings because it'd create a redirect loop.")); |