@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | } |
61 | 61 | // Query the db table |
62 | 62 | $stats = (new Query()) |
63 | - ->from(['{{%retour_stats}}']) |
|
63 | + ->from([ '{{%retour_stats}}' ]) |
|
64 | 64 | ->orderBy('hitCount DESC') |
65 | 65 | ->limit(Retour::$settings->statsDisplayLimit) |
66 | 66 | ->all(); |
@@ -79,13 +79,13 @@ discard block |
||
79 | 79 | public function getRecentStatistics($days = 1, $handled = false): array |
80 | 80 | { |
81 | 81 | // Ensure is an int |
82 | - $handledInt = (int)$handled; |
|
83 | - $stats = []; |
|
82 | + $handledInt = (int) $handled; |
|
83 | + $stats = [ ]; |
|
84 | 84 | $db = Craft::$app->getDb(); |
85 | 85 | if ($db->getIsMysql()) { |
86 | 86 | // Query the db table |
87 | 87 | $stats = (new Query()) |
88 | - ->from(['{{%retour_stats}}']) |
|
88 | + ->from([ '{{%retour_stats}}' ]) |
|
89 | 89 | ->where("hitLastTime >= ( CURDATE() - INTERVAL '{$days}' DAY )") |
90 | 90 | ->andWhere("handledByRetour = {$handledInt}") |
91 | 91 | ->orderBy('hitLastTime DESC') |
@@ -94,9 +94,9 @@ discard block |
||
94 | 94 | if ($db->getIsPgsql()) { |
95 | 95 | // Query the db table |
96 | 96 | $stats = (new Query()) |
97 | - ->from(['{{%retour_stats}}']) |
|
97 | + ->from([ '{{%retour_stats}}' ]) |
|
98 | 98 | ->where("\"hitLastTime\" >= ( CURRENT_TIMESTAMP - INTERVAL '{$days} days' )") |
99 | - ->andWhere(['handledByRetour' => $handledInt]) |
|
99 | + ->andWhere([ 'handledByRetour' => $handledInt ]) |
|
100 | 100 | ->orderBy('hitLastTime DESC') |
101 | 101 | ->all(); |
102 | 102 | } |
@@ -163,16 +163,16 @@ discard block |
||
163 | 163 | $stats->validate(); |
164 | 164 | // Find any existing retour_stats record |
165 | 165 | $statsConfig = (new Query()) |
166 | - ->from(['{{%retour_stats}}']) |
|
167 | - ->where(['redirectSrcUrl' => $stats->redirectSrcUrl]) |
|
166 | + ->from([ '{{%retour_stats}}' ]) |
|
167 | + ->where([ 'redirectSrcUrl' => $stats->redirectSrcUrl ]) |
|
168 | 168 | ->one(); |
169 | 169 | // If no record is found, initialize some values |
170 | 170 | if ($statsConfig === null) { |
171 | 171 | $stats->id = 0; |
172 | 172 | $stats->hitCount = 0; |
173 | 173 | } else { |
174 | - $stats->id = $statsConfig['id']; |
|
175 | - $stats->hitCount = $statsConfig['hitCount']; |
|
174 | + $stats->id = $statsConfig[ 'id' ]; |
|
175 | + $stats->hitCount = $statsConfig[ 'hitCount' ]; |
|
176 | 176 | } |
177 | 177 | // Merge in the updated info |
178 | 178 | $stats->siteId = $siteId; |
@@ -181,9 +181,9 @@ discard block |
||
181 | 181 | $stats->userAgent = $userAgent; |
182 | 182 | $stats->exceptionMessage = $exceptionMessage; |
183 | 183 | $stats->exceptionFilePath = $exceptionFilePath; |
184 | - $stats->exceptionFileLine = (int)$exceptionFileLine; |
|
184 | + $stats->exceptionFileLine = (int) $exceptionFileLine; |
|
185 | 185 | $stats->hitLastTime = Db::prepareDateForDb(new \DateTime()); |
186 | - $stats->handledByRetour = (int)$handled; |
|
186 | + $stats->handledByRetour = (int) $handled; |
|
187 | 187 | $stats->hitCount++; |
188 | 188 | $statsConfig = $stats->getAttributes(); |
189 | 189 | // Record the updated statistics |
@@ -253,7 +253,7 @@ discard block |
||
253 | 253 | Craft::t( |
254 | 254 | 'retour', |
255 | 255 | 'Trimmed {rows} from retour_stats table', |
256 | - ['rows' => $affectedRows] |
|
256 | + [ 'rows' => $affectedRows ] |
|
257 | 257 | ), |
258 | 258 | __METHOD__ |
259 | 259 | ); |
@@ -274,7 +274,7 @@ discard block |
||
274 | 274 | Craft::t( |
275 | 275 | 'retour', |
276 | 276 | 'Error validating statistics {id}: {errors}', |
277 | - ['id' => $stats->id, 'errors' => print_r($stats->getErrors(), true)] |
|
277 | + [ 'id' => $stats->id, 'errors' => print_r($stats->getErrors(), true) ] |
|
278 | 278 | ), |
279 | 279 | __METHOD__ |
280 | 280 | ); |
@@ -284,14 +284,14 @@ discard block |
||
284 | 284 | // Get the validated model attributes and save them to the db |
285 | 285 | $statsConfig = $stats->getAttributes(); |
286 | 286 | $db = Craft::$app->getDb(); |
287 | - if ($statsConfig['id'] !== 0) { |
|
287 | + if ($statsConfig[ 'id' ] !== 0) { |
|
288 | 288 | // Update the existing record |
289 | 289 | try { |
290 | 290 | $result = $db->createCommand()->update( |
291 | 291 | '{{%retour_stats}}', |
292 | 292 | $statsConfig, |
293 | 293 | [ |
294 | - 'id' => $statsConfig['id'], |
|
294 | + 'id' => $statsConfig[ 'id' ], |
|
295 | 295 | ] |
296 | 296 | )->execute(); |
297 | 297 | } catch (Exception $e) { |
@@ -300,7 +300,7 @@ discard block |
||
300 | 300 | // Craft::error($e->getMessage(), __METHOD__); |
301 | 301 | } |
302 | 302 | } else { |
303 | - unset($statsConfig['id']); |
|
303 | + unset($statsConfig[ 'id' ]); |
|
304 | 304 | // Create a new record |
305 | 305 | try { |
306 | 306 | $db->createCommand()->insert( |
@@ -327,7 +327,7 @@ discard block |
||
327 | 327 | $now = round(microtime(true) * 1000); |
328 | 328 | $cache = Craft::$app->getCache(); |
329 | 329 | $then = $cache->get(self::LAST_STATISTICS_TRIM_CACHE_KEY); |
330 | - if (($then !== false) && ($now - (int)$then < Retour::$settings->statisticsRateLimitMs)) { |
|
330 | + if (($then !== false) && ($now - (int) $then < Retour::$settings->statisticsRateLimitMs)) { |
|
331 | 331 | $limited = true; |
332 | 332 | } |
333 | 333 | $cache->set(self::LAST_STATISTICS_TRIM_CACHE_KEY, $now, 0); |
@@ -62,36 +62,36 @@ discard block |
||
62 | 62 | // Boolean field |
63 | 63 | $retourField |
64 | 64 | ->addBooleanField($field) |
65 | - ->resolve(function ($redirect) use ($field) { |
|
66 | - $result = $redirect[$field] ?? null; |
|
67 | - return $result === null ? $result : (bool)$result; |
|
65 | + ->resolve(function($redirect) use ($field) { |
|
66 | + $result = $redirect[ $field ] ?? null; |
|
67 | + return $result === null ? $result : (bool) $result; |
|
68 | 68 | }); |
69 | 69 | } elseif (in_array($field, self::INT_FIELDS, true)) { |
70 | 70 | // Integer field |
71 | 71 | $retourField |
72 | 72 | ->addIntField($field) |
73 | - ->resolve(function ($redirect) use ($field) { |
|
74 | - $result = $redirect[$field] ?? null; |
|
75 | - return $result === null ? $result : (int)$result; |
|
73 | + ->resolve(function($redirect) use ($field) { |
|
74 | + $result = $redirect[ $field ] ?? null; |
|
75 | + return $result === null ? $result : (int) $result; |
|
76 | 76 | }); |
77 | 77 | } else { |
78 | 78 | // String field |
79 | 79 | $retourField |
80 | 80 | ->addStringField($field) |
81 | - ->resolve(function ($redirect) use ($field) { |
|
82 | - $result = $redirect[$field] ?? null; |
|
83 | - return $result === null ? $result : (string)$result; |
|
81 | + ->resolve(function($redirect) use ($field) { |
|
82 | + $result = $redirect[ $field ] ?? null; |
|
83 | + return $result === null ? $result : (string) $result; |
|
84 | 84 | }); |
85 | 85 | } |
86 | 86 | } |
87 | 87 | // Add the root |
88 | 88 | $event->schema->addField('retour') |
89 | - ->arguments(function (FieldBuilder $field) { |
|
89 | + ->arguments(function(FieldBuilder $field) { |
|
90 | 90 | $field->addStringArgument('uri'); |
91 | 91 | $field->addIntArgument('siteId'); |
92 | 92 | }) |
93 | 93 | ->type($retourField) |
94 | - ->resolve(function ($root, $args, $context, $info) { |
|
94 | + ->resolve(function($root, $args, $context, $info) { |
|
95 | 95 | // If our root is an Element, extract the URI and siteId from it |
96 | 96 | if ($root instanceof Element) { |
97 | 97 | /** Element $root */ |
@@ -99,8 +99,8 @@ discard block |
||
99 | 99 | $siteId = $root->siteId; |
100 | 100 | } else { |
101 | 101 | // Otherwise use the passed in arguments, or defaults |
102 | - $uri = $args['uri'] ?? '/'; |
|
103 | - $siteId = $args['siteId'] ?? null; |
|
102 | + $uri = $args[ 'uri' ] ?? '/'; |
|
103 | + $siteId = $args[ 'siteId' ] ?? null; |
|
104 | 104 | } |
105 | 105 | $uri = trim($uri === '/' ? '__home__' : $uri); |
106 | 106 |
@@ -104,7 +104,7 @@ discard block |
||
104 | 104 | /** |
105 | 105 | * @var array The URIs for the element before it was saved |
106 | 106 | */ |
107 | - public $oldElementUris = []; |
|
107 | + public $oldElementUris = [ ]; |
|
108 | 108 | |
109 | 109 | // Public Methods |
110 | 110 | // ========================================================================= |
@@ -135,7 +135,7 @@ discard block |
||
135 | 135 | Craft::t( |
136 | 136 | 'retour', |
137 | 137 | '{name} plugin loaded', |
138 | - ['name' => $this->name] |
|
138 | + [ 'name' => $this->name ] |
|
139 | 139 | ), |
140 | 140 | __METHOD__ |
141 | 141 | ); |
@@ -155,18 +155,18 @@ discard block |
||
155 | 155 | */ |
156 | 156 | public function getCpNavItem() |
157 | 157 | { |
158 | - $subNavs = []; |
|
158 | + $subNavs = [ ]; |
|
159 | 159 | $navItem = parent::getCpNavItem(); |
160 | 160 | $currentUser = Craft::$app->getUser()->getIdentity(); |
161 | 161 | // Only show sub-navs the user has permission to view |
162 | 162 | if ($currentUser->can('retour:dashboard')) { |
163 | - $subNavs['dashboard'] = [ |
|
163 | + $subNavs[ 'dashboard' ] = [ |
|
164 | 164 | 'label' => 'Dashboard', |
165 | 165 | 'url' => 'retour/dashboard', |
166 | 166 | ]; |
167 | 167 | } |
168 | 168 | if ($currentUser->can('retour:redirects')) { |
169 | - $subNavs['redirects'] = [ |
|
169 | + $subNavs[ 'redirects' ] = [ |
|
170 | 170 | 'label' => 'Redirects', |
171 | 171 | 'url' => 'retour/redirects', |
172 | 172 | ]; |
@@ -177,7 +177,7 @@ discard block |
||
177 | 177 | $editableSettings = false; |
178 | 178 | } |
179 | 179 | if ($currentUser->can('retour:settings') && $editableSettings) { |
180 | - $subNavs['settings'] = [ |
|
180 | + $subNavs[ 'settings' ] = [ |
|
181 | 181 | 'label' => 'Settings', |
182 | 182 | 'url' => 'retour/settings', |
183 | 183 | ]; |
@@ -236,7 +236,7 @@ discard block |
||
236 | 236 | Event::on( |
237 | 237 | ClearCaches::class, |
238 | 238 | ClearCaches::EVENT_REGISTER_CACHE_OPTIONS, |
239 | - function (RegisterCacheOptionsEvent $event) { |
|
239 | + function(RegisterCacheOptionsEvent $event) { |
|
240 | 240 | Craft::debug( |
241 | 241 | 'ClearCaches::EVENT_REGISTER_CACHE_OPTIONS', |
242 | 242 | __METHOD__ |
@@ -252,7 +252,7 @@ discard block |
||
252 | 252 | Event::on( |
253 | 253 | Plugins::class, |
254 | 254 | Plugins::EVENT_AFTER_INSTALL_PLUGIN, |
255 | - function (PluginEvent $event) { |
|
255 | + function(PluginEvent $event) { |
|
256 | 256 | if ($event->plugin === $this) { |
257 | 257 | // Invalidate our caches after we've been installed |
258 | 258 | $this->clearAllCaches(); |
@@ -279,7 +279,7 @@ discard block |
||
279 | 279 | Event::on( |
280 | 280 | CraftVariable::class, |
281 | 281 | CraftVariable::EVENT_INIT, |
282 | - function (Event $event) { |
|
282 | + function(Event $event) { |
|
283 | 283 | /** @var CraftVariable $variable */ |
284 | 284 | $variable = $event->sender; |
285 | 285 | $variable->set('retour', RetourVariable::class); |
@@ -289,7 +289,7 @@ discard block |
||
289 | 289 | Event::on( |
290 | 290 | Elements::class, |
291 | 291 | Elements::EVENT_BEFORE_SAVE_ELEMENT, |
292 | - function (ElementEvent $event) { |
|
292 | + function(ElementEvent $event) { |
|
293 | 293 | Craft::debug( |
294 | 294 | 'Elements::EVENT_BEFORE_SAVE_ELEMENT', |
295 | 295 | __METHOD__ |
@@ -304,8 +304,8 @@ discard block |
||
304 | 304 | if ($oldElement !== null) { |
305 | 305 | // Stash the old URLs by element id, and do so only once, |
306 | 306 | // in case we are called more than once per request |
307 | - if (empty($this->oldElementUris[$oldElement->id])) { |
|
308 | - $this->oldElementUris[$oldElement->id] = $this->getAllElementUris($oldElement); |
|
307 | + if (empty($this->oldElementUris[ $oldElement->id ])) { |
|
308 | + $this->oldElementUris[ $oldElement->id ] = $this->getAllElementUris($oldElement); |
|
309 | 309 | } |
310 | 310 | } |
311 | 311 | } |
@@ -316,7 +316,7 @@ discard block |
||
316 | 316 | Event::on( |
317 | 317 | Elements::class, |
318 | 318 | Elements::EVENT_AFTER_SAVE_ELEMENT, |
319 | - function (ElementEvent $event) { |
|
319 | + function(ElementEvent $event) { |
|
320 | 320 | Craft::debug( |
321 | 321 | 'Elements::EVENT_AFTER_SAVE_ELEMENT', |
322 | 322 | __METHOD__ |
@@ -332,7 +332,7 @@ discard block |
||
332 | 332 | Event::on( |
333 | 333 | Plugins::class, |
334 | 334 | Plugins::EVENT_AFTER_LOAD_PLUGINS, |
335 | - function () { |
|
335 | + function() { |
|
336 | 336 | // Install these only after all other plugins have loaded |
337 | 337 | $request = Craft::$app->getRequest(); |
338 | 338 | // Only respond to non-console site requests |
@@ -350,7 +350,7 @@ discard block |
||
350 | 350 | Event::on( |
351 | 351 | Schema::class, |
352 | 352 | AlterSchemaFields::EVENT, |
353 | - [GetCraftQLSchema::class, 'handle'] |
|
353 | + [ GetCraftQLSchema::class, 'handle' ] |
|
354 | 354 | ); |
355 | 355 | } |
356 | 356 | } |
@@ -364,7 +364,7 @@ discard block |
||
364 | 364 | Event::on( |
365 | 365 | UrlManager::class, |
366 | 366 | UrlManager::EVENT_REGISTER_SITE_URL_RULES, |
367 | - function (RegisterUrlRulesEvent $event) { |
|
367 | + function(RegisterUrlRulesEvent $event) { |
|
368 | 368 | Craft::debug( |
369 | 369 | 'UrlManager::EVENT_REGISTER_SITE_URL_RULES', |
370 | 370 | __METHOD__ |
@@ -387,15 +387,15 @@ discard block |
||
387 | 387 | Event::on( |
388 | 388 | Dashboard::class, |
389 | 389 | Dashboard::EVENT_REGISTER_WIDGET_TYPES, |
390 | - function (RegisterComponentTypesEvent $event) { |
|
391 | - $event->types[] = RetourWidget::class; |
|
390 | + function(RegisterComponentTypesEvent $event) { |
|
391 | + $event->types[ ] = RetourWidget::class; |
|
392 | 392 | } |
393 | 393 | ); |
394 | 394 | // Handler: UrlManager::EVENT_REGISTER_CP_URL_RULES |
395 | 395 | Event::on( |
396 | 396 | UrlManager::class, |
397 | 397 | UrlManager::EVENT_REGISTER_CP_URL_RULES, |
398 | - function (RegisterUrlRulesEvent $event) { |
|
398 | + function(RegisterUrlRulesEvent $event) { |
|
399 | 399 | Craft::debug( |
400 | 400 | 'UrlManager::EVENT_REGISTER_CP_URL_RULES', |
401 | 401 | __METHOD__ |
@@ -411,13 +411,13 @@ discard block |
||
411 | 411 | Event::on( |
412 | 412 | UserPermissions::class, |
413 | 413 | UserPermissions::EVENT_REGISTER_PERMISSIONS, |
414 | - function (RegisterUserPermissionsEvent $event) { |
|
414 | + function(RegisterUserPermissionsEvent $event) { |
|
415 | 415 | Craft::debug( |
416 | 416 | 'UserPermissions::EVENT_REGISTER_PERMISSIONS', |
417 | 417 | __METHOD__ |
418 | 418 | ); |
419 | 419 | // Register our custom permissions |
420 | - $event->permissions[Craft::t('retour', 'Retour')] = $this->customAdminCpPermissions(); |
|
420 | + $event->permissions[ Craft::t('retour', 'Retour') ] = $this->customAdminCpPermissions(); |
|
421 | 421 | } |
422 | 422 | ); |
423 | 423 | } |
@@ -433,7 +433,7 @@ discard block |
||
433 | 433 | Event::on( |
434 | 434 | ErrorHandler::class, |
435 | 435 | ErrorHandler::EVENT_BEFORE_HANDLE_EXCEPTION, |
436 | - function (ExceptionEvent $event) { |
|
436 | + function(ExceptionEvent $event) { |
|
437 | 437 | Craft::debug( |
438 | 438 | 'ErrorHandler::EVENT_BEFORE_HANDLE_EXCEPTION', |
439 | 439 | __METHOD__ |
@@ -476,16 +476,16 @@ discard block |
||
476 | 476 | protected function handleElementUriChange(Element $element) |
477 | 477 | { |
478 | 478 | $uris = $this->getAllElementUris($element); |
479 | - if (!empty($this->oldElementUris[$element->id])) { |
|
480 | - $oldElementUris = $this->oldElementUris[$element->id]; |
|
479 | + if (!empty($this->oldElementUris[ $element->id ])) { |
|
480 | + $oldElementUris = $this->oldElementUris[ $element->id ]; |
|
481 | 481 | foreach ($uris as $siteId => $newUri) { |
482 | - if (!empty($oldElementUris[$siteId])) { |
|
483 | - $oldUri = $oldElementUris[$siteId]; |
|
482 | + if (!empty($oldElementUris[ $siteId ])) { |
|
483 | + $oldUri = $oldElementUris[ $siteId ]; |
|
484 | 484 | Craft::debug( |
485 | 485 | Craft::t( |
486 | 486 | 'retour', |
487 | 487 | 'Comparing old: {oldUri} to new: {newUri}', |
488 | - ['oldUri' => print_r($oldUri, true), 'newUri' => print_r($newUri, true)] |
|
488 | + [ 'oldUri' => print_r($oldUri, true), 'newUri' => print_r($newUri, true) ] |
|
489 | 489 | ), |
490 | 490 | __METHOD__ |
491 | 491 | ); |
@@ -520,12 +520,12 @@ discard block |
||
520 | 520 | */ |
521 | 521 | protected function getAllElementUris(Element $element): array |
522 | 522 | { |
523 | - $uris = []; |
|
523 | + $uris = [ ]; |
|
524 | 524 | $sites = Craft::$app->getSites()->getAllSites(); |
525 | 525 | foreach ($sites as $site) { |
526 | 526 | $uri = Craft::$app->getElements()->getElementUriForSite($element->id, $site->id); |
527 | 527 | if ($uri !== null) { |
528 | - $uris[$site->id] = $uri; |
|
528 | + $uris[ $site->id ] = $uri; |
|
529 | 529 | } |
530 | 530 | } |
531 | 531 | |
@@ -533,7 +533,7 @@ discard block |
||
533 | 533 | Craft::t( |
534 | 534 | 'retour', |
535 | 535 | 'Getting Element URIs: {uris}', |
536 | - ['uris' => print_r($uris, true)] |
|
536 | + [ 'uris' => print_r($uris, true) ] |
|
537 | 537 | ), |
538 | 538 | __METHOD__ |
539 | 539 | ); |
@@ -597,7 +597,7 @@ discard block |
||
597 | 597 | [ |
598 | 598 | 'key' => 'retour-redirect-caches', |
599 | 599 | 'label' => Craft::t('retour', 'Retour redirect caches'), |
600 | - 'action' => [self::$plugin->redirects, 'invalidateCaches'], |
|
600 | + 'action' => [ self::$plugin->redirects, 'invalidateCaches' ], |
|
601 | 601 | ], |
602 | 602 | ]; |
603 | 603 | } |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | // Protected Properties |
74 | 74 | // ========================================================================= |
75 | 75 | |
76 | - protected $allowAnonymous = []; |
|
76 | + protected $allowAnonymous = [ ]; |
|
77 | 77 | |
78 | 78 | // Public Methods |
79 | 79 | // ========================================================================= |
@@ -115,20 +115,20 @@ discard block |
||
115 | 115 | if ($headers !== null) { |
116 | 116 | $csv->setOffset(1); |
117 | 117 | $columns = ArrayHelper::filterEmptyStringsFromArray($columns); |
118 | - $csv->each(function ($row) use ($headers, $columns) { |
|
118 | + $csv->each(function($row) use ($headers, $columns) { |
|
119 | 119 | $redirectConfig = [ |
120 | 120 | 'id' => 0, |
121 | 121 | ]; |
122 | 122 | $index = 0; |
123 | 123 | foreach (self::IMPORT_REDIRECTS_CSV_FIELDS as $importField) { |
124 | - if (isset($columns[$index], $headers[$columns[$index]])) { |
|
125 | - $redirectConfig[$importField] = empty($row[$headers[$columns[$index]]]) |
|
124 | + if (isset($columns[ $index ], $headers[ $columns[ $index ] ])) { |
|
125 | + $redirectConfig[ $importField ] = empty($row[ $headers[ $columns[ $index ] ] ]) |
|
126 | 126 | ? null |
127 | - : $row[$headers[$columns[$index]]]; |
|
127 | + : $row[ $headers[ $columns[ $index ] ] ]; |
|
128 | 128 | } |
129 | 129 | $index++; |
130 | 130 | } |
131 | - Craft::debug('Importing row: '.print_r($redirectConfig, true), __METHOD__); |
|
131 | + Craft::debug('Importing row: ' . print_r($redirectConfig, true), __METHOD__); |
|
132 | 132 | Retour::$plugin->redirects->saveRedirect($redirectConfig); |
133 | 133 | |
134 | 134 | return true; |
@@ -152,7 +152,7 @@ discard block |
||
152 | 152 | */ |
153 | 153 | public function actionImportCsv(string $siteHandle = null): Response |
154 | 154 | { |
155 | - $variables = []; |
|
155 | + $variables = [ ]; |
|
156 | 156 | PermissionHelper::controllerPermissionCheck('retour:redirects'); |
157 | 157 | // If your CSV document was created or is read on a Macintosh computer, |
158 | 158 | // add the following lines before using the library to help PHP detect line ending in Mac OS X |
@@ -170,38 +170,38 @@ discard block |
||
170 | 170 | } catch (InvalidConfigException $e) { |
171 | 171 | Craft::error($e->getMessage(), __METHOD__); |
172 | 172 | } |
173 | - $variables['baseAssetsUrl'] = Craft::$app->assetManager->getPublishedUrl( |
|
173 | + $variables[ 'baseAssetsUrl' ] = Craft::$app->assetManager->getPublishedUrl( |
|
174 | 174 | '@nystudio107/retour/assetbundles/retour/dist', |
175 | 175 | true |
176 | 176 | ); |
177 | 177 | // Enabled sites |
178 | 178 | MultiSiteHelper::setMultiSiteVariables($siteHandle, $siteId, $variables); |
179 | - $variables['controllerHandle'] = 'file'; |
|
179 | + $variables[ 'controllerHandle' ] = 'file'; |
|
180 | 180 | |
181 | 181 | // Basic variables |
182 | - $variables['fullPageForm'] = true; |
|
183 | - $variables['docsUrl'] = self::DOCUMENTATION_URL; |
|
184 | - $variables['pluginName'] = $pluginName; |
|
185 | - $variables['title'] = $templateTitle; |
|
186 | - $siteHandleUri = Craft::$app->isMultiSite ? '/'.$siteHandle : ''; |
|
187 | - $variables['crumbs'] = [ |
|
182 | + $variables[ 'fullPageForm' ] = true; |
|
183 | + $variables[ 'docsUrl' ] = self::DOCUMENTATION_URL; |
|
184 | + $variables[ 'pluginName' ] = $pluginName; |
|
185 | + $variables[ 'title' ] = $templateTitle; |
|
186 | + $siteHandleUri = Craft::$app->isMultiSite ? '/' . $siteHandle : ''; |
|
187 | + $variables[ 'crumbs' ] = [ |
|
188 | 188 | [ |
189 | 189 | 'label' => $pluginName, |
190 | 190 | 'url' => UrlHelper::cpUrl('retour'), |
191 | 191 | ], |
192 | 192 | [ |
193 | 193 | 'label' => 'Redirects', |
194 | - 'url' => UrlHelper::cpUrl('retour/redirects'.$siteHandleUri), |
|
194 | + 'url' => UrlHelper::cpUrl('retour/redirects' . $siteHandleUri), |
|
195 | 195 | ], |
196 | 196 | ]; |
197 | - $variables['docTitle'] = "{$pluginName} - Redirects - {$templateTitle}"; |
|
198 | - $variables['selectedSubnavItem'] = 'redirects'; |
|
197 | + $variables[ 'docTitle' ] = "{$pluginName} - Redirects - {$templateTitle}"; |
|
198 | + $variables[ 'selectedSubnavItem' ] = 'redirects'; |
|
199 | 199 | |
200 | 200 | // The CSV file |
201 | 201 | $file = UploadedFile::getInstanceByName('file'); |
202 | 202 | if ($file !== null) { |
203 | 203 | $filename = uniqid($file->name, true); |
204 | - $filePath = Craft::$app->getPath()->getTempPath().DIRECTORY_SEPARATOR.$filename; |
|
204 | + $filePath = Craft::$app->getPath()->getTempPath() . DIRECTORY_SEPARATOR . $filename; |
|
205 | 205 | $file->saveAs($filePath, false); |
206 | 206 | // Also save the file to the cache as a backup way to access it |
207 | 207 | $cache = Craft::$app->getCache(); |
@@ -217,8 +217,8 @@ discard block |
||
217 | 217 | $csv = Reader::createFromPath($file->tempName); |
218 | 218 | $headers = $csv->fetchOne(0); |
219 | 219 | Craft::info(print_r($headers, true), __METHOD__); |
220 | - $variables['headers'] = $headers; |
|
221 | - $variables['filename'] = $filePath; |
|
220 | + $variables[ 'headers' ] = $headers; |
|
221 | + $variables[ 'filename' ] = $filePath; |
|
222 | 222 | } |
223 | 223 | |
224 | 224 | // Render the template |
@@ -264,7 +264,7 @@ discard block |
||
264 | 264 | } |
265 | 265 | // Query the db table |
266 | 266 | $data = (new Query()) |
267 | - ->from([$table]) |
|
267 | + ->from([ $table ]) |
|
268 | 268 | ->select(array_keys($columns)) |
269 | 269 | ->orderBy('hitCount DESC') |
270 | 270 | ->all(); |
@@ -272,7 +272,7 @@ discard block |
||
272 | 272 | $csv = Writer::createFromFileObject(new \SplTempFileObject()); |
273 | 273 | $csv->insertOne(array_values($columns)); |
274 | 274 | $csv->insertAll($data); |
275 | - $csv->output($filename.'.csv'); |
|
275 | + $csv->output($filename . '.csv'); |
|
276 | 276 | exit(0); |
277 | 277 | } |
278 | 278 | } |
@@ -166,7 +166,7 @@ discard block |
||
166 | 166 | Craft::t( |
167 | 167 | 'retour', |
168 | 168 | '404 full URL: {fullUrl}, 404 path only: {pathOnly}', |
169 | - ['fullUrl' => $fullUrl, 'pathOnly' => $pathOnly] |
|
169 | + [ 'fullUrl' => $fullUrl, 'pathOnly' => $pathOnly ] |
|
170 | 170 | ), |
171 | 171 | __METHOD__ |
172 | 172 | ); |
@@ -200,7 +200,7 @@ discard block |
||
200 | 200 | $response = Craft::$app->getResponse(); |
201 | 201 | if ($redirect !== null) { |
202 | 202 | // Figure out what type of source matching was done |
203 | - $redirectSrcMatch = $redirect['redirectSrcMatch'] ?? 'pathonly'; |
|
203 | + $redirectSrcMatch = $redirect[ 'redirectSrcMatch' ] ?? 'pathonly'; |
|
204 | 204 | switch ($redirectSrcMatch) { |
205 | 205 | case 'pathonly': |
206 | 206 | $url = $pathOnly; |
@@ -212,11 +212,11 @@ discard block |
||
212 | 212 | $url = $pathOnly; |
213 | 213 | break; |
214 | 214 | } |
215 | - $dest = $redirect['redirectDestUrl']; |
|
215 | + $dest = $redirect[ 'redirectDestUrl' ]; |
|
216 | 216 | // If this isn't a full URL, make it one based on the appropriate site |
217 | 217 | if (!UrlHelper::isFullUrl($dest)) { |
218 | 218 | try { |
219 | - $dest = UrlHelper::siteUrl($dest, null, null, $redirect['siteId'] ?? null); |
|
219 | + $dest = UrlHelper::siteUrl($dest, null, null, $redirect[ 'siteId' ] ?? null); |
|
220 | 220 | } catch (\yii\base\Exception $e) { |
221 | 221 | } |
222 | 222 | } |
@@ -226,12 +226,12 @@ discard block |
||
226 | 226 | $dest .= '?' . $request->getQueryStringWithoutPath(); |
227 | 227 | } |
228 | 228 | } |
229 | - $status = $redirect['redirectHttpCode']; |
|
229 | + $status = $redirect[ 'redirectHttpCode' ]; |
|
230 | 230 | Craft::info( |
231 | 231 | Craft::t( |
232 | 232 | 'retour', |
233 | 233 | 'Redirecting {url} to {dest} with status {status}', |
234 | - ['url' => $url, 'dest' => $dest, 'status' => $status] |
|
234 | + [ 'url' => $url, 'dest' => $dest, 'status' => $status ] |
|
235 | 235 | ), |
236 | 236 | __METHOD__ |
237 | 237 | ); |
@@ -313,13 +313,13 @@ discard block |
||
313 | 313 | public function getRedirectFromCache($url, int $siteId = 0) |
314 | 314 | { |
315 | 315 | $cache = Craft::$app->getCache(); |
316 | - $cacheKey = $this::CACHE_KEY.md5($url).$siteId; |
|
316 | + $cacheKey = $this::CACHE_KEY . md5($url) . $siteId; |
|
317 | 317 | $redirect = $cache->get($cacheKey); |
318 | 318 | Craft::info( |
319 | 319 | Craft::t( |
320 | 320 | 'retour', |
321 | 321 | 'Cached redirect hit for {url}', |
322 | - ['url' => $url] |
|
322 | + [ 'url' => $url ] |
|
323 | 323 | ), |
324 | 324 | __METHOD__ |
325 | 325 | ); |
@@ -341,12 +341,12 @@ discard block |
||
341 | 341 | } catch (SiteNotFoundException $e) { |
342 | 342 | $siteId = 1; |
343 | 343 | } |
344 | - $cacheKey = $this::CACHE_KEY.md5($url).$siteId; |
|
344 | + $cacheKey = $this::CACHE_KEY . md5($url) . $siteId; |
|
345 | 345 | // Create the dependency tags |
346 | 346 | $dependency = new TagDependency([ |
347 | 347 | 'tags' => [ |
348 | 348 | $this::GLOBAL_REDIRECTS_CACHE_TAG, |
349 | - $this::GLOBAL_REDIRECTS_CACHE_TAG.$siteId, |
|
349 | + $this::GLOBAL_REDIRECTS_CACHE_TAG . $siteId, |
|
350 | 350 | ], |
351 | 351 | ]); |
352 | 352 | $cache->set($cacheKey, $redirect, Retour::$cacheDuration, $dependency); |
@@ -354,7 +354,7 @@ discard block |
||
354 | 354 | Craft::t( |
355 | 355 | 'retour', |
356 | 356 | 'Cached redirect saved for {url}', |
357 | - ['url' => $url] |
|
357 | + [ 'url' => $url ] |
|
358 | 358 | ), |
359 | 359 | __METHOD__ |
360 | 360 | ); |
@@ -384,8 +384,8 @@ discard block |
||
384 | 384 | // Iterate through the redirects |
385 | 385 | foreach ($redirects as $redirect) { |
386 | 386 | // Figure out what type of source matching to do |
387 | - $redirectSrcMatch = $redirect['redirectSrcMatch'] ?? 'pathonly'; |
|
388 | - $redirectEnabled = (bool)$redirect['enabled']; |
|
387 | + $redirectSrcMatch = $redirect[ 'redirectSrcMatch' ] ?? 'pathonly'; |
|
388 | + $redirectEnabled = (bool) $redirect[ 'enabled' ]; |
|
389 | 389 | if ($redirectEnabled === true) { |
390 | 390 | switch ($redirectSrcMatch) { |
391 | 391 | case 'pathonly': |
@@ -398,11 +398,11 @@ discard block |
||
398 | 398 | $url = $pathOnly; |
399 | 399 | break; |
400 | 400 | } |
401 | - $redirectMatchType = $redirect['redirectMatchType'] ?? 'notfound'; |
|
401 | + $redirectMatchType = $redirect[ 'redirectMatchType' ] ?? 'notfound'; |
|
402 | 402 | switch ($redirectMatchType) { |
403 | 403 | // Do a straight up match |
404 | 404 | case 'exactmatch': |
405 | - if (strcasecmp($redirect['redirectSrcUrlParsed'], $url) === 0) { |
|
405 | + if (strcasecmp($redirect[ 'redirectSrcUrlParsed' ], $url) === 0) { |
|
406 | 406 | $this->incrementRedirectHitCount($redirect); |
407 | 407 | $this->saveRedirectToCache($url, $redirect); |
408 | 408 | |
@@ -412,14 +412,14 @@ discard block |
||
412 | 412 | |
413 | 413 | // Do a regex match |
414 | 414 | case 'regexmatch': |
415 | - $matchRegEx = '`'.$redirect['redirectSrcUrlParsed'].'`i'; |
|
415 | + $matchRegEx = '`' . $redirect[ 'redirectSrcUrlParsed' ] . '`i'; |
|
416 | 416 | if (preg_match($matchRegEx, $url) === 1) { |
417 | 417 | $this->incrementRedirectHitCount($redirect); |
418 | 418 | // If we're not associated with an EntryID, handle capture group replacement |
419 | - if ((int)$redirect['associatedElementId'] === 0) { |
|
420 | - $redirect['redirectDestUrl'] = preg_replace( |
|
419 | + if ((int) $redirect[ 'associatedElementId' ] === 0) { |
|
420 | + $redirect[ 'redirectDestUrl' ] = preg_replace( |
|
421 | 421 | $matchRegEx, |
422 | - $redirect['redirectDestUrl'], |
|
422 | + $redirect[ 'redirectDestUrl' ], |
|
423 | 423 | $url |
424 | 424 | ); |
425 | 425 | } |
@@ -438,7 +438,7 @@ discard block |
||
438 | 438 | 'redirect' => &$redirect, |
439 | 439 | ], |
440 | 440 | ]; |
441 | - $result = \call_user_func_array([$plugin, 'retourMatch'], $args); |
|
441 | + $result = \call_user_func_array([ $plugin, 'retourMatch' ], $args); |
|
442 | 442 | if ($result) { |
443 | 443 | $this->incrementRedirectHitCount($redirect); |
444 | 444 | $this->saveRedirectToCache($url, $redirect); |
@@ -465,7 +465,7 @@ discard block |
||
465 | 465 | Craft::t( |
466 | 466 | 'retour', |
467 | 467 | 'Not handled-> full URL: {fullUrl}, path only: {pathOnly}', |
468 | - ['fullUrl' => $fullUrl, 'pathOnly' => $pathOnly] |
|
468 | + [ 'fullUrl' => $fullUrl, 'pathOnly' => $pathOnly ] |
|
469 | 469 | ), |
470 | 470 | __METHOD__ |
471 | 471 | ); |
@@ -501,7 +501,7 @@ discard block |
||
501 | 501 | foreach (Craft::$app->getPlugins()->getAllPlugins() as $plugin) { |
502 | 502 | /** @var Plugin $plugin */ |
503 | 503 | if (method_exists($plugin, 'retourMatch')) { |
504 | - $result[$plugin->getHandle()] = $plugin->name.Craft::t('retour', ' Match'); |
|
504 | + $result[ $plugin->getHandle() ] = $plugin->name . Craft::t('retour', ' Match'); |
|
505 | 505 | } |
506 | 506 | } |
507 | 507 | |
@@ -522,12 +522,12 @@ discard block |
||
522 | 522 | } |
523 | 523 | // Query the db table |
524 | 524 | $query = (new Query()) |
525 | - ->from(['{{%retour_static_redirects}}']) |
|
525 | + ->from([ '{{%retour_static_redirects}}' ]) |
|
526 | 526 | ->orderBy('redirectMatchType ASC, redirectSrcMatch ASC, hitCount DESC'); |
527 | 527 | if ($siteId) { |
528 | 528 | $query |
529 | - ->where(['siteId' => $siteId]) |
|
530 | - ->orWhere(['siteId' => null]); |
|
529 | + ->where([ 'siteId' => $siteId ]) |
|
530 | + ->orWhere([ 'siteId' => null ]); |
|
531 | 531 | } |
532 | 532 | if ($limit) { |
533 | 533 | $query->limit($limit); |
@@ -550,8 +550,8 @@ discard block |
||
550 | 550 | { |
551 | 551 | // Query the db table |
552 | 552 | $redirect = (new Query()) |
553 | - ->from(['{{%retour_static_redirects}}']) |
|
554 | - ->where(['id' => $id]) |
|
553 | + ->from([ '{{%retour_static_redirects}}' ]) |
|
554 | + ->where([ 'id' => $id ]) |
|
555 | 555 | ->one(); |
556 | 556 | |
557 | 557 | return $redirect; |
@@ -569,16 +569,16 @@ discard block |
||
569 | 569 | { |
570 | 570 | // Query the db table |
571 | 571 | $query = (new Query()) |
572 | - ->from(['{{%retour_static_redirects}}']) |
|
573 | - ->where(['redirectSrcUrl' => $redirectSrcUrl]) |
|
572 | + ->from([ '{{%retour_static_redirects}}' ]) |
|
573 | + ->where([ 'redirectSrcUrl' => $redirectSrcUrl ]) |
|
574 | 574 | ; |
575 | 575 | if ($siteId) { |
576 | 576 | $query |
577 | - ->andWhere(['or', [ |
|
577 | + ->andWhere([ 'or', [ |
|
578 | 578 | 'siteId' => $siteId, |
579 | 579 | ], [ |
580 | 580 | 'siteId' => null, |
581 | - ]]); |
|
581 | + ] ]); |
|
582 | 582 | } |
583 | 583 | $redirect = $query->one(); |
584 | 584 | |
@@ -620,13 +620,13 @@ discard block |
||
620 | 620 | { |
621 | 621 | if ($redirectConfig !== null) { |
622 | 622 | $db = Craft::$app->getDb(); |
623 | - $redirectConfig['hitCount']++; |
|
624 | - $redirectConfig['hitLastTime'] = Db::prepareDateForDb(new \DateTime()); |
|
623 | + $redirectConfig[ 'hitCount' ]++; |
|
624 | + $redirectConfig[ 'hitLastTime' ] = Db::prepareDateForDb(new \DateTime()); |
|
625 | 625 | Craft::debug( |
626 | 626 | Craft::t( |
627 | 627 | 'retour', |
628 | 628 | 'Incrementing statistics for: {redirect}', |
629 | - ['redirect' => print_r($redirectConfig, true)] |
|
629 | + [ 'redirect' => print_r($redirectConfig, true) ] |
|
630 | 630 | ), |
631 | 631 | __METHOD__ |
632 | 632 | ); |
@@ -635,14 +635,14 @@ discard block |
||
635 | 635 | $rowsAffected = $db->createCommand()->update( |
636 | 636 | '{{%retour_static_redirects}}', |
637 | 637 | [ |
638 | - 'hitCount' => $redirectConfig['hitCount'], |
|
639 | - 'hitLastTime' => $redirectConfig['hitLastTime'], |
|
638 | + 'hitCount' => $redirectConfig[ 'hitCount' ], |
|
639 | + 'hitLastTime' => $redirectConfig[ 'hitLastTime' ], |
|
640 | 640 | ], |
641 | 641 | [ |
642 | - 'id' => $redirectConfig['id'], |
|
642 | + 'id' => $redirectConfig[ 'id' ], |
|
643 | 643 | ] |
644 | 644 | )->execute(); |
645 | - Craft::debug('Rows affected: '.$rowsAffected, __METHOD__); |
|
645 | + Craft::debug('Rows affected: ' . $rowsAffected, __METHOD__); |
|
646 | 646 | } catch (Exception $e) { |
647 | 647 | Craft::error($e->getMessage(), __METHOD__); |
648 | 648 | } |
@@ -661,7 +661,7 @@ discard block |
||
661 | 661 | Craft::t( |
662 | 662 | 'retour', |
663 | 663 | 'Error validating redirect {id}: {errors}', |
664 | - ['id' => $redirect->id, 'errors' => print_r($redirect->getErrors(), true)] |
|
664 | + [ 'id' => $redirect->id, 'errors' => print_r($redirect->getErrors(), true) ] |
|
665 | 665 | ), |
666 | 666 | __METHOD__ |
667 | 667 | ); |
@@ -671,32 +671,32 @@ discard block |
||
671 | 671 | // Get the validated model attributes and save them to the db |
672 | 672 | $redirectConfig = $redirect->getAttributes(); |
673 | 673 | // 0 for a siteId needs to be converted to null |
674 | - if (empty($redirectConfig['siteId']) || (int)$redirectConfig['siteId'] === 0) { |
|
675 | - $redirectConfig['siteId'] = null; |
|
674 | + if (empty($redirectConfig[ 'siteId' ]) || (int) $redirectConfig[ 'siteId' ] === 0) { |
|
675 | + $redirectConfig[ 'siteId' ] = null; |
|
676 | 676 | } |
677 | 677 | // Throw an event to before saving the redirect |
678 | 678 | $db = Craft::$app->getDb(); |
679 | 679 | // See if a redirect exists with this source URL already |
680 | - if ((int)$redirectConfig['id'] === 0) { |
|
680 | + if ((int) $redirectConfig[ 'id' ] === 0) { |
|
681 | 681 | // Query the db table |
682 | 682 | $redirect = (new Query()) |
683 | - ->from(['{{%retour_static_redirects}}']) |
|
684 | - ->where(['redirectSrcUrlParsed' => $redirectConfig['redirectSrcUrlParsed']]) |
|
685 | - ->andWhere(['siteId' => $redirectConfig['siteId']]) |
|
683 | + ->from([ '{{%retour_static_redirects}}' ]) |
|
684 | + ->where([ 'redirectSrcUrlParsed' => $redirectConfig[ 'redirectSrcUrlParsed' ] ]) |
|
685 | + ->andWhere([ 'siteId' => $redirectConfig[ 'siteId' ] ]) |
|
686 | 686 | ->one(); |
687 | 687 | // If it exists, update it rather than having duplicates |
688 | 688 | if (!empty($redirect)) { |
689 | - $redirectConfig['id'] = $redirect['id']; |
|
689 | + $redirectConfig[ 'id' ] = $redirect[ 'id' ]; |
|
690 | 690 | } |
691 | 691 | } |
692 | 692 | // Trigger a 'beforeSaveRedirect' event |
693 | - $isNew = (int)$redirectConfig['id'] === 0; |
|
693 | + $isNew = (int) $redirectConfig[ 'id' ] === 0; |
|
694 | 694 | $event = new RedirectEvent([ |
695 | 695 | 'isNew' => $isNew, |
696 | - 'legacyUrl' => $redirectConfig['redirectSrcUrlParsed'], |
|
697 | - 'destinationUrl' => $redirectConfig['redirectDestUrl'], |
|
698 | - 'matchType' => $redirectConfig['redirectSrcMatch'], |
|
699 | - 'redirectType' => $redirectConfig['redirectHttpCode'], |
|
696 | + 'legacyUrl' => $redirectConfig[ 'redirectSrcUrlParsed' ], |
|
697 | + 'destinationUrl' => $redirectConfig[ 'redirectDestUrl' ], |
|
698 | + 'matchType' => $redirectConfig[ 'redirectSrcMatch' ], |
|
699 | + 'redirectType' => $redirectConfig[ 'redirectHttpCode' ], |
|
700 | 700 | ]); |
701 | 701 | $this->trigger(self::EVENT_BEFORE_SAVE_REDIRECT, $event); |
702 | 702 | if (!$event->isValid) { |
@@ -708,7 +708,7 @@ discard block |
||
708 | 708 | Craft::t( |
709 | 709 | 'retour', |
710 | 710 | 'Updating existing redirect: {redirect}', |
711 | - ['redirect' => print_r($redirectConfig, true)] |
|
711 | + [ 'redirect' => print_r($redirectConfig, true) ] |
|
712 | 712 | ), |
713 | 713 | __METHOD__ |
714 | 714 | ); |
@@ -718,7 +718,7 @@ discard block |
||
718 | 718 | '{{%retour_static_redirects}}', |
719 | 719 | $redirectConfig, |
720 | 720 | [ |
721 | - 'id' => $redirectConfig['id'], |
|
721 | + 'id' => $redirectConfig[ 'id' ], |
|
722 | 722 | ] |
723 | 723 | )->execute(); |
724 | 724 | } catch (Exception $e) { |
@@ -729,11 +729,11 @@ discard block |
||
729 | 729 | Craft::t( |
730 | 730 | 'retour', |
731 | 731 | 'Creating new redirect: {redirect}', |
732 | - ['redirect' => print_r($redirectConfig, true)] |
|
732 | + [ 'redirect' => print_r($redirectConfig, true) ] |
|
733 | 733 | ), |
734 | 734 | __METHOD__ |
735 | 735 | ); |
736 | - unset($redirectConfig['id']); |
|
736 | + unset($redirectConfig[ 'id' ]); |
|
737 | 737 | // Create a new record |
738 | 738 | try { |
739 | 739 | $db->createCommand()->insert( |
@@ -746,15 +746,15 @@ discard block |
||
746 | 746 | } |
747 | 747 | // To prevent redirect loops, see if any static redirects have our redirectDestUrl as their redirectSrcUrl |
748 | 748 | $testRedirectConfig = $this->getRedirectByRedirectSrcUrl( |
749 | - $redirectConfig['redirectDestUrl'], |
|
750 | - $redirectConfig['siteId'] |
|
749 | + $redirectConfig[ 'redirectDestUrl' ], |
|
750 | + $redirectConfig[ 'siteId' ] |
|
751 | 751 | ); |
752 | 752 | if ($testRedirectConfig !== null) { |
753 | 753 | Craft::debug( |
754 | 754 | Craft::t( |
755 | 755 | 'retour', |
756 | 756 | 'Deleting redirect to prevent a loop: {redirect}', |
757 | - ['redirect' => print_r($testRedirectConfig, true)] |
|
757 | + [ 'redirect' => print_r($testRedirectConfig, true) ] |
|
758 | 758 | ), |
759 | 759 | __METHOD__ |
760 | 760 | ); |
@@ -762,7 +762,7 @@ discard block |
||
762 | 762 | try { |
763 | 763 | $db->createCommand()->delete( |
764 | 764 | '{{%retour_static_redirects}}', |
765 | - ['id' => $testRedirectConfig['id']] |
|
765 | + [ 'id' => $testRedirectConfig[ 'id' ] ] |
|
766 | 766 | )->execute(); |
767 | 767 | } catch (Exception $e) { |
768 | 768 | Craft::error($e->getMessage(), __METHOD__); |
@@ -795,10 +795,10 @@ discard block |
||
795 | 795 | */ |
796 | 796 | public function excludeUri($uri): bool |
797 | 797 | { |
798 | - $uri = '/'.ltrim($uri, '/'); |
|
798 | + $uri = '/' . ltrim($uri, '/'); |
|
799 | 799 | if (!empty(Retour::$settings->excludePatterns)) { |
800 | 800 | foreach (Retour::$settings->excludePatterns as $excludePattern) { |
801 | - $pattern = '`'.$excludePattern['pattern'].'`i'; |
|
801 | + $pattern = '`' . $excludePattern[ 'pattern' ] . '`i'; |
|
802 | 802 | if (preg_match($pattern, $uri) === 1) { |
803 | 803 | return true; |
804 | 804 | } |