@@ -39,7 +39,7 @@ |
||
39 | 39 | /** @noinspection CallableParameterUseCaseInTypeContextInspection */ |
40 | 40 | $url = preg_replace('/{.*}/', '', $url); |
41 | 41 | // Remove any linebreaks that may be errantly in the URL |
42 | - $url = (string)str_replace([ |
|
42 | + $url = (string) str_replace([ |
|
43 | 43 | PHP_EOL, |
44 | 44 | "\r", |
45 | 45 | "\n", |
@@ -57,6 +57,6 @@ |
||
57 | 57 | { |
58 | 58 | $redirects = Retour::$plugin->redirects->getAllStaticRedirects(null, $siteId); |
59 | 59 | |
60 | - return $this->asJson($redirects ?? []); |
|
60 | + return $this->asJson($redirects ?? [ ]); |
|
61 | 61 | } |
62 | 62 | } |
@@ -135,8 +135,8 @@ discard block |
||
135 | 135 | public function rules() |
136 | 136 | { |
137 | 137 | return [ |
138 | - ['pluginName', 'string'], |
|
139 | - ['pluginName', 'default', 'value' => 'Retour'], |
|
138 | + [ 'pluginName', 'string' ], |
|
139 | + [ 'pluginName', 'default', 'value' => 'Retour' ], |
|
140 | 140 | [ |
141 | 141 | [ |
142 | 142 | 'createUriChangeRedirects', |
@@ -147,22 +147,22 @@ discard block |
||
147 | 147 | ], |
148 | 148 | 'boolean', |
149 | 149 | ], |
150 | - ['uriChangeRedirectSrcMatch', 'default', 'value' => 'pathonly'], |
|
151 | - ['uriChangeRedirectSrcMatch', 'string'], |
|
152 | - ['uriChangeRedirectSrcMatch', 'in', 'range' => [ |
|
150 | + [ 'uriChangeRedirectSrcMatch', 'default', 'value' => 'pathonly' ], |
|
151 | + [ 'uriChangeRedirectSrcMatch', 'string' ], |
|
152 | + [ 'uriChangeRedirectSrcMatch', 'in', 'range' => [ |
|
153 | 153 | 'pathonly', |
154 | 154 | 'fullurl' |
155 | - ]], |
|
156 | - ['staticRedirectDisplayLimit', 'integer', 'min' => 1], |
|
157 | - ['staticRedirectDisplayLimit', 'default', 'value' => 100], |
|
158 | - ['dynamicRedirectDisplayLimit', 'integer', 'min' => 1], |
|
159 | - ['dynamicRedirectDisplayLimit', 'default', 'value' => 100], |
|
160 | - ['statsStoredLimit', 'integer', 'min' => 1], |
|
161 | - ['statsStoredLimit', 'default', 'value' => 1000], |
|
162 | - ['refreshIntervalSecs', 'integer', 'min' => 0], |
|
163 | - ['refreshIntervalSecs', 'default', 'value' => 3], |
|
164 | - ['statsDisplayLimit', 'integer', 'min' => 1], |
|
165 | - ['statsDisplayLimit', 'default', 'value' => 1000], |
|
155 | + ] ], |
|
156 | + [ 'staticRedirectDisplayLimit', 'integer', 'min' => 1 ], |
|
157 | + [ 'staticRedirectDisplayLimit', 'default', 'value' => 100 ], |
|
158 | + [ 'dynamicRedirectDisplayLimit', 'integer', 'min' => 1 ], |
|
159 | + [ 'dynamicRedirectDisplayLimit', 'default', 'value' => 100 ], |
|
160 | + [ 'statsStoredLimit', 'integer', 'min' => 1 ], |
|
161 | + [ 'statsStoredLimit', 'default', 'value' => 1000 ], |
|
162 | + [ 'refreshIntervalSecs', 'integer', 'min' => 0 ], |
|
163 | + [ 'refreshIntervalSecs', 'default', 'value' => 3 ], |
|
164 | + [ 'statsDisplayLimit', 'integer', 'min' => 1 ], |
|
165 | + [ 'statsDisplayLimit', 'default', 'value' => 1000 ], |
|
166 | 166 | [ |
167 | 167 | [ |
168 | 168 | 'excludePatterns', |
@@ -178,7 +178,7 @@ discard block |
||
178 | 178 | */ |
179 | 179 | public function behaviors() |
180 | 180 | { |
181 | - $craft31Behaviors = []; |
|
181 | + $craft31Behaviors = [ ]; |
|
182 | 182 | if (Retour::$craft31) { |
183 | 183 | $craft31Behaviors = [ |
184 | 184 | 'parser' => [ |
@@ -57,7 +57,7 @@ |
||
57 | 57 | // Determines whether the Retour API endpoint should be enabled for anonymous frontend access |
58 | 58 | 'enableApiEndpoint' => false, |
59 | 59 | |
60 | - // [Regular expressions](https://regexr.com/) to match URLs to exclude from tracking |
|
60 | + // [Regular expressions](https://regexr.com/) to match URLs to exclude from tracking |
|
61 | 61 | 'excludePatterns' => [ |
62 | 62 | ], |
63 | 63 |
@@ -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 | } |
@@ -97,7 +97,7 @@ discard block |
||
97 | 97 | $handled = 'all' |
98 | 98 | ): Response { |
99 | 99 | PermissionHelper::controllerPermissionCheck('retour:dashboard'); |
100 | - $data = []; |
|
100 | + $data = [ ]; |
|
101 | 101 | $sortField = 'hitCount'; |
102 | 102 | $sortType = 'DESC'; |
103 | 103 | // Figure out the sorting type |
@@ -109,7 +109,7 @@ discard block |
||
109 | 109 | } |
110 | 110 | } |
111 | 111 | $sortType = strtoupper($sortType); |
112 | - $sortType = self::SORT_MAP[$sortType] ?? self::SORT_MAP['DESC']; |
|
112 | + $sortType = self::SORT_MAP[ $sortType ] ?? self::SORT_MAP[ 'DESC' ]; |
|
113 | 113 | // Validate untrusted data |
114 | 114 | if (!in_array($sortField, self::ALLOWED_STATS_SORT_FIELDS, true)) { |
115 | 115 | throw new BadRequestHttpException(Craft::t('retour', 'Invalid sort field specified.')); |
@@ -117,46 +117,46 @@ discard block |
||
117 | 117 | // Query the db table |
118 | 118 | $offset = ($page - 1) * $per_page; |
119 | 119 | $query = (new Query()) |
120 | - ->from(['{{%retour_stats}}']) |
|
120 | + ->from([ '{{%retour_stats}}' ]) |
|
121 | 121 | ->offset($offset) |
122 | 122 | ->limit($per_page) |
123 | - ->orderBy([$sortField => $sortType]) |
|
124 | - ->filterWhere(['like', 'redirectSrcUrl', $filter]) |
|
125 | - ->orFilterWhere(['like', 'referrerUrl', $filter]) |
|
123 | + ->orderBy([ $sortField => $sortType ]) |
|
124 | + ->filterWhere([ 'like', 'redirectSrcUrl', $filter ]) |
|
125 | + ->orFilterWhere([ 'like', 'referrerUrl', $filter ]) |
|
126 | 126 | ; |
127 | - if ((int)$siteId !== 0) { |
|
128 | - $query->andWhere(['siteId' => $siteId]); |
|
127 | + if ((int) $siteId !== 0) { |
|
128 | + $query->andWhere([ 'siteId' => $siteId ]); |
|
129 | 129 | } |
130 | 130 | if ($handled !== 'all') { |
131 | - $query->andWhere(['handledByRetour' => self::HANDLED_MAP[$handled]]); |
|
131 | + $query->andWhere([ 'handledByRetour' => self::HANDLED_MAP[ $handled ] ]); |
|
132 | 132 | } |
133 | 133 | $stats = $query->all(); |
134 | 134 | if ($stats) { |
135 | 135 | // Add in the `addLink` field |
136 | 136 | foreach ($stats as &$stat) { |
137 | - $stat['addLink'] = ''; |
|
138 | - if (!$stat['handledByRetour']) { |
|
139 | - $encodedUrl = urlencode('/'.ltrim($stat['redirectSrcUrl'], '/')); |
|
137 | + $stat[ 'addLink' ] = ''; |
|
138 | + if (!$stat[ 'handledByRetour' ]) { |
|
139 | + $encodedUrl = urlencode('/' . ltrim($stat[ 'redirectSrcUrl' ], '/')); |
|
140 | 140 | // Add the siteId to the URL, but keep the current behavior of passing in siteId=0 for "all" |
141 | - $statSiteId = $stat['siteId'] ?? 0; |
|
141 | + $statSiteId = $stat[ 'siteId' ] ?? 0; |
|
142 | 142 | try { |
143 | 143 | $primarySite = Craft::$app->getSites()->getPrimarySite(); |
144 | 144 | } catch (SiteNotFoundException $e) { |
145 | 145 | $primarySite = null; |
146 | 146 | } |
147 | - if ($primarySite !== null && $statSiteId == (int)$primarySite->id) { |
|
147 | + if ($primarySite !== null && $statSiteId == (int) $primarySite->id) { |
|
148 | 148 | $statSiteId = 0; |
149 | 149 | } |
150 | - $stat['addLink'] = UrlHelper::cpUrl('retour/add-redirect', [ |
|
150 | + $stat[ 'addLink' ] = UrlHelper::cpUrl('retour/add-redirect', [ |
|
151 | 151 | 'defaultUrl' => $encodedUrl, |
152 | 152 | 'siteId' => $statSiteId |
153 | 153 | ]); |
154 | 154 | } |
155 | 155 | } |
156 | 156 | // Format the data for the API |
157 | - $data['data'] = $stats; |
|
157 | + $data[ 'data' ] = $stats; |
|
158 | 158 | $count = $query->count(); |
159 | - $data['links']['pagination'] = [ |
|
159 | + $data[ 'links' ][ 'pagination' ] = [ |
|
160 | 160 | 'total' => $count, |
161 | 161 | 'per_page' => $per_page, |
162 | 162 | 'current_page' => $page, |
@@ -192,7 +192,7 @@ discard block |
||
192 | 192 | $siteId = 0 |
193 | 193 | ): Response { |
194 | 194 | PermissionHelper::controllerPermissionCheck('retour:redirects'); |
195 | - $data = []; |
|
195 | + $data = [ ]; |
|
196 | 196 | $sortField = 'hitCount'; |
197 | 197 | $sortType = 'DESC'; |
198 | 198 | // Figure out the sorting type |
@@ -204,7 +204,7 @@ discard block |
||
204 | 204 | } |
205 | 205 | } |
206 | 206 | $sortType = strtoupper($sortType); |
207 | - $sortType = self::SORT_MAP[$sortType] ?? self::SORT_MAP['DESC']; |
|
207 | + $sortType = self::SORT_MAP[ $sortType ] ?? self::SORT_MAP[ 'DESC' ]; |
|
208 | 208 | // Validate untrusted data |
209 | 209 | if (!in_array($sortField, self::ALLOWED_REDIRECTS_SORT_FIELDS, true)) { |
210 | 210 | throw new BadRequestHttpException(Craft::t('retour', 'Invalid sort field specified.')); |
@@ -212,42 +212,42 @@ discard block |
||
212 | 212 | // Query the db table |
213 | 213 | $offset = ($page - 1) * $per_page; |
214 | 214 | $query = (new Query()) |
215 | - ->from(['{{%retour_static_redirects}}']) |
|
215 | + ->from([ '{{%retour_static_redirects}}' ]) |
|
216 | 216 | ->offset($offset) |
217 | 217 | ->limit($per_page) |
218 | - ->orderBy([$sortField => $sortType]) |
|
219 | - ->filterWhere(['like', 'redirectSrcUrl', $filter]) |
|
220 | - ->orFilterWhere(['like', 'redirectDestUrl', $filter]) |
|
218 | + ->orderBy([ $sortField => $sortType ]) |
|
219 | + ->filterWhere([ 'like', 'redirectSrcUrl', $filter ]) |
|
220 | + ->orFilterWhere([ 'like', 'redirectDestUrl', $filter ]) |
|
221 | 221 | ; |
222 | - if ((int)$siteId !== 0) { |
|
223 | - $query->andWhere(['siteId' => $siteId]); |
|
222 | + if ((int) $siteId !== 0) { |
|
223 | + $query->andWhere([ 'siteId' => $siteId ]); |
|
224 | 224 | } |
225 | 225 | $redirects = $query->all(); |
226 | 226 | // Add in the `deleteLink` field and clean up the redirects |
227 | 227 | foreach ($redirects as &$redirect) { |
228 | 228 | // Make sure the destination URL is not a regex |
229 | - if ($redirect['redirectMatchType'] !== 'exactmatch') { |
|
230 | - if (preg_match("/\$\d+/", $redirect['redirectDestUrl'])) { |
|
231 | - $redirect['redirectDestUrl'] = ''; |
|
229 | + if ($redirect[ 'redirectMatchType' ] !== 'exactmatch') { |
|
230 | + if (preg_match("/\$\d+/", $redirect[ 'redirectDestUrl' ])) { |
|
231 | + $redirect[ 'redirectDestUrl' ] = ''; |
|
232 | 232 | } |
233 | 233 | } |
234 | 234 | // Handle extracting the site name |
235 | - $redirect['siteName'] = Craft::t('retour', 'All Sites'); |
|
236 | - if ($redirect['siteId']) { |
|
235 | + $redirect[ 'siteName' ] = Craft::t('retour', 'All Sites'); |
|
236 | + if ($redirect[ 'siteId' ]) { |
|
237 | 237 | $sites = Craft::$app->getSites(); |
238 | - $site = $sites->getSiteById($redirect['siteId']); |
|
238 | + $site = $sites->getSiteById($redirect[ 'siteId' ]); |
|
239 | 239 | if ($site) { |
240 | - $redirect['siteName'] = $site->name; |
|
240 | + $redirect[ 'siteName' ] = $site->name; |
|
241 | 241 | } |
242 | 242 | } |
243 | 243 | |
244 | - $redirect['editLink'] = UrlHelper::cpUrl('retour/edit-redirect/'.$redirect['id']); |
|
244 | + $redirect[ 'editLink' ] = UrlHelper::cpUrl('retour/edit-redirect/' . $redirect[ 'id' ]); |
|
245 | 245 | } |
246 | 246 | // Format the data for the API |
247 | 247 | if ($redirects) { |
248 | - $data['data'] = $redirects; |
|
248 | + $data[ 'data' ] = $redirects; |
|
249 | 249 | $count = $query->count(); |
250 | - $data['links']['pagination'] = [ |
|
250 | + $data[ 'links' ][ 'pagination' ] = [ |
|
251 | 251 | 'total' => $count, |
252 | 252 | 'per_page' => $per_page, |
253 | 253 | 'current_page' => $page, |
@@ -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,17 +251,17 @@ 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 | - if ($generalConfig->addTrailingSlashesToUrls && $redirectConfig['redirectMatchType'] === 'exactmatch') { |
|
258 | - $destUrl = $redirectConfig['redirectDestUrl'] ?? ''; |
|
259 | - $redirectConfig['redirectDestUrl'] = $this->addSlashToSiteUrls($destUrl); |
|
257 | + if ($generalConfig->addTrailingSlashesToUrls && $redirectConfig[ 'redirectMatchType' ] === 'exactmatch') { |
|
258 | + $destUrl = $redirectConfig[ 'redirectDestUrl' ] ?? ''; |
|
259 | + $redirectConfig[ 'redirectDestUrl' ] = $this->addSlashToSiteUrls($destUrl); |
|
260 | 260 | } |
261 | 261 | // Handle URL encoded URLs by decoding them before saving them |
262 | - if ($redirectConfig['redirectMatchType'] === 'exactmatch') { |
|
263 | - $redirectConfig['redirectSrcUrl'] = urldecode($redirectConfig['redirectSrcUrl'] ?? ''); |
|
264 | - $redirectConfig['redirectSrcUrlParsed'] = urldecode($redirectConfig['redirectSrcUrlParsed'] ?? ''); |
|
262 | + if ($redirectConfig[ 'redirectMatchType' ] === 'exactmatch') { |
|
263 | + $redirectConfig[ 'redirectSrcUrl' ] = urldecode($redirectConfig[ 'redirectSrcUrl' ] ?? ''); |
|
264 | + $redirectConfig[ 'redirectSrcUrlParsed' ] = urldecode($redirectConfig[ 'redirectSrcUrlParsed' ] ?? ''); |
|
265 | 265 | } |
266 | 266 | $redirect = new StaticRedirectsModel($redirectConfig); |
267 | 267 | // Make sure the redirect validates |
@@ -279,8 +279,8 @@ discard block |
||
279 | 279 | Retour::$plugin->redirects->saveRedirect($redirectConfig); |
280 | 280 | // Handle the case where the redirect wasn't saved because it'd create a redirect loop |
281 | 281 | $testRedirectConfig = Retour::$plugin->redirects->getRedirectByRedirectSrcUrl( |
282 | - $redirectConfig['redirectSrcUrl'], |
|
283 | - $redirectConfig['siteId'] |
|
282 | + $redirectConfig[ 'redirectSrcUrl' ], |
|
283 | + $redirectConfig[ 'siteId' ] |
|
284 | 284 | ); |
285 | 285 | if ($testRedirectConfig === null) { |
286 | 286 | Craft::$app->getSession()->setError(Craft::t('app', "Couldn't save redirect settings because it'd create a redirect loop.")); |
@@ -20,10 +20,10 @@ |
||
20 | 20 | $schemaVersion = $projectConfig->get('plugins.retour.schemaVersion', true); |
21 | 21 | |
22 | 22 | if (version_compare($schemaVersion, '3.0.10', '<')) { |
23 | - foreach ($projectConfig->get('graphql.schemas') ?? [] as $schemaUid => $schemaComponents) { |
|
24 | - if (isset($schemaComponents['scope'])) { |
|
25 | - $scope = $schemaComponents['scope']; |
|
26 | - $scope[] = 'retour.all:read'; |
|
23 | + foreach ($projectConfig->get('graphql.schemas') ?? [ ] as $schemaUid => $schemaComponents) { |
|
24 | + if (isset($schemaComponents[ 'scope' ])) { |
|
25 | + $scope = $schemaComponents[ 'scope' ]; |
|
26 | + $scope[ ] = 'retour.all:read'; |
|
27 | 27 | |
28 | 28 | $projectConfig->set("graphql.schemas.$schemaUid.scope", $scope); |
29 | 29 | } |
@@ -17,6 +17,6 @@ |
||
17 | 17 | { |
18 | 18 | $allowedEntities = self::extractAllowedEntitiesFromSchema(); |
19 | 19 | |
20 | - return isset($allowedEntities['retour']); |
|
20 | + return isset($allowedEntities[ 'retour' ]); |
|
21 | 21 | } |
22 | 22 | } |
@@ -34,7 +34,7 @@ |
||
34 | 34 | public static function getQueries($checkToken = true): array |
35 | 35 | { |
36 | 36 | if ($checkToken && !GqlHelper::canQueryRetour()) { |
37 | - return []; |
|
37 | + return [ ]; |
|
38 | 38 | } |
39 | 39 | |
40 | 40 | return [ |