@@ -34,24 +34,24 @@ |
||
34 | 34 | */ |
35 | 35 | public static function generateTypes($context = null): array |
36 | 36 | { |
37 | - $gqlTypes = []; |
|
37 | + $gqlTypes = [ ]; |
|
38 | 38 | $retourFields = RetourInterface::getFieldDefinitions(); |
39 | 39 | $retourArgs = RetourArguments::getArguments(); |
40 | 40 | $typeName = self::getName(); |
41 | 41 | $retourType = GqlEntityRegistry::getEntity($typeName) |
42 | 42 | ?: GqlEntityRegistry::createEntity($typeName, new RetourType([ |
43 | 43 | 'name' => $typeName, |
44 | - 'args' => function () use ($retourArgs) { |
|
44 | + 'args' => function() use ($retourArgs) { |
|
45 | 45 | return $retourArgs; |
46 | 46 | }, |
47 | - 'fields' => function () use ($retourFields) { |
|
47 | + 'fields' => function() use ($retourFields) { |
|
48 | 48 | return $retourFields; |
49 | 49 | }, |
50 | 50 | 'description' => 'This entity has all the Retour fields', |
51 | 51 | ])); |
52 | 52 | |
53 | - $gqlTypes[$typeName] = $retourType; |
|
54 | - TypeLoader::registerType($typeName, function () use ($retourType) { |
|
53 | + $gqlTypes[ $typeName ] = $retourType; |
|
54 | + TypeLoader::registerType($typeName, function() use ($retourType) { |
|
55 | 55 | return $retourType; |
56 | 56 | }); |
57 | 57 |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | // Protected Properties |
41 | 41 | // ========================================================================= |
42 | 42 | |
43 | - protected $allowAnonymous = []; |
|
43 | + protected $allowAnonymous = [ ]; |
|
44 | 44 | |
45 | 45 | // Public Methods |
46 | 46 | // ========================================================================= |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | */ |
57 | 57 | public function actionDashboard(string $siteHandle = null, bool $showWelcome = false): Response |
58 | 58 | { |
59 | - $variables = []; |
|
59 | + $variables = [ ]; |
|
60 | 60 | PermissionHelper::controllerPermissionCheck('retour:dashboard'); |
61 | 61 | // Trim the statistics |
62 | 62 | Retour::$plugin->statistics->trimStatistics(); |
@@ -71,34 +71,34 @@ discard block |
||
71 | 71 | } catch (InvalidConfigException $e) { |
72 | 72 | Craft::error($e->getMessage(), __METHOD__); |
73 | 73 | } |
74 | - $variables['baseAssetsUrl'] = Craft::$app->assetManager->getPublishedUrl( |
|
74 | + $variables[ 'baseAssetsUrl' ] = Craft::$app->assetManager->getPublishedUrl( |
|
75 | 75 | '@nystudio107/retour/assetbundles/retour/dist', |
76 | 76 | true |
77 | 77 | ); |
78 | 78 | // Enabled sites |
79 | 79 | MultiSiteHelper::setMultiSiteVariables($siteHandle, $siteId, $variables); |
80 | - $variables['controllerHandle'] = 'dashboard'; |
|
80 | + $variables[ 'controllerHandle' ] = 'dashboard'; |
|
81 | 81 | |
82 | 82 | // Basic variables |
83 | - $variables['fullPageForm'] = false; |
|
84 | - $variables['docsUrl'] = self::DOCUMENTATION_URL; |
|
85 | - $variables['pluginName'] = $pluginName; |
|
86 | - $variables['title'] = $templateTitle; |
|
87 | - $siteHandleUri = Craft::$app->isMultiSite ? '/'.$siteHandle : ''; |
|
88 | - $variables['crumbs'] = [ |
|
83 | + $variables[ 'fullPageForm' ] = false; |
|
84 | + $variables[ 'docsUrl' ] = self::DOCUMENTATION_URL; |
|
85 | + $variables[ 'pluginName' ] = $pluginName; |
|
86 | + $variables[ 'title' ] = $templateTitle; |
|
87 | + $siteHandleUri = Craft::$app->isMultiSite ? '/' . $siteHandle : ''; |
|
88 | + $variables[ 'crumbs' ] = [ |
|
89 | 89 | [ |
90 | 90 | 'label' => $pluginName, |
91 | 91 | 'url' => UrlHelper::cpUrl('retour'), |
92 | 92 | ], |
93 | 93 | [ |
94 | 94 | 'label' => $templateTitle, |
95 | - 'url' => UrlHelper::cpUrl('retour/dashboard'.$siteHandleUri), |
|
95 | + 'url' => UrlHelper::cpUrl('retour/dashboard' . $siteHandleUri), |
|
96 | 96 | ], |
97 | 97 | ]; |
98 | - $variables['docTitle'] = "{$pluginName} - {$templateTitle}"; |
|
99 | - $variables['selectedSubnavItem'] = 'dashboard'; |
|
100 | - $variables['showWelcome'] = $showWelcome; |
|
101 | - $variables['settings'] = Retour::$settings; |
|
98 | + $variables[ 'docTitle' ] = "{$pluginName} - {$templateTitle}"; |
|
99 | + $variables[ 'selectedSubnavItem' ] = 'dashboard'; |
|
100 | + $variables[ 'showWelcome' ] = $showWelcome; |
|
101 | + $variables[ 'settings' ] = Retour::$settings; |
|
102 | 102 | |
103 | 103 | // Render the template |
104 | 104 | return $this->renderTemplate('retour/dashboard/index', $variables); |
@@ -116,7 +116,7 @@ discard block |
||
116 | 116 | Craft::t( |
117 | 117 | 'retour', |
118 | 118 | 'Retour statistics cleared: {error}', |
119 | - ['error' => $error] |
|
119 | + [ 'error' => $error ] |
|
120 | 120 | ), |
121 | 121 | __METHOD__ |
122 | 122 | ); |
@@ -149,7 +149,7 @@ discard block |
||
149 | 149 | Craft::t( |
150 | 150 | 'retour', |
151 | 151 | 'Retour statistics deleted: {error}', |
152 | - ['error' => $stickyError] |
|
152 | + [ 'error' => $stickyError ] |
|
153 | 153 | ), |
154 | 154 | __METHOD__ |
155 | 155 | ); |
@@ -121,7 +121,7 @@ discard block |
||
121 | 121 | /** |
122 | 122 | * @var array The URIs for the element before it was saved |
123 | 123 | */ |
124 | - public $oldElementUris = []; |
|
124 | + public $oldElementUris = [ ]; |
|
125 | 125 | |
126 | 126 | // Public Methods |
127 | 127 | // ========================================================================= |
@@ -154,7 +154,7 @@ discard block |
||
154 | 154 | Craft::t( |
155 | 155 | 'retour', |
156 | 156 | '{name} plugin loaded', |
157 | - ['name' => $this->name] |
|
157 | + [ 'name' => $this->name ] |
|
158 | 158 | ), |
159 | 159 | __METHOD__ |
160 | 160 | ); |
@@ -174,18 +174,18 @@ discard block |
||
174 | 174 | */ |
175 | 175 | public function getCpNavItem() |
176 | 176 | { |
177 | - $subNavs = []; |
|
177 | + $subNavs = [ ]; |
|
178 | 178 | $navItem = parent::getCpNavItem(); |
179 | 179 | $currentUser = Craft::$app->getUser()->getIdentity(); |
180 | 180 | // Only show sub-navs the user has permission to view |
181 | 181 | if ($currentUser->can('retour:dashboard')) { |
182 | - $subNavs['dashboard'] = [ |
|
182 | + $subNavs[ 'dashboard' ] = [ |
|
183 | 183 | 'label' => 'Dashboard', |
184 | 184 | 'url' => 'retour/dashboard', |
185 | 185 | ]; |
186 | 186 | } |
187 | 187 | if ($currentUser->can('retour:redirects')) { |
188 | - $subNavs['redirects'] = [ |
|
188 | + $subNavs[ 'redirects' ] = [ |
|
189 | 189 | 'label' => 'Redirects', |
190 | 190 | 'url' => 'retour/redirects', |
191 | 191 | ]; |
@@ -196,7 +196,7 @@ discard block |
||
196 | 196 | $editableSettings = false; |
197 | 197 | } |
198 | 198 | if ($currentUser->can('retour:settings') && $editableSettings) { |
199 | - $subNavs['settings'] = [ |
|
199 | + $subNavs[ 'settings' ] = [ |
|
200 | 200 | 'label' => 'Settings', |
201 | 201 | 'url' => 'retour/settings', |
202 | 202 | ]; |
@@ -255,7 +255,7 @@ discard block |
||
255 | 255 | Event::on( |
256 | 256 | ClearCaches::class, |
257 | 257 | ClearCaches::EVENT_REGISTER_CACHE_OPTIONS, |
258 | - function (RegisterCacheOptionsEvent $event) { |
|
258 | + function(RegisterCacheOptionsEvent $event) { |
|
259 | 259 | Craft::debug( |
260 | 260 | 'ClearCaches::EVENT_REGISTER_CACHE_OPTIONS', |
261 | 261 | __METHOD__ |
@@ -271,7 +271,7 @@ discard block |
||
271 | 271 | Event::on( |
272 | 272 | Plugins::class, |
273 | 273 | Plugins::EVENT_AFTER_INSTALL_PLUGIN, |
274 | - function (PluginEvent $event) { |
|
274 | + function(PluginEvent $event) { |
|
275 | 275 | if ($event->plugin === $this) { |
276 | 276 | // Invalidate our caches after we've been installed |
277 | 277 | $this->clearAllCaches(); |
@@ -298,7 +298,7 @@ discard block |
||
298 | 298 | Event::on( |
299 | 299 | CraftVariable::class, |
300 | 300 | CraftVariable::EVENT_INIT, |
301 | - function (Event $event) { |
|
301 | + function(Event $event) { |
|
302 | 302 | /** @var CraftVariable $variable */ |
303 | 303 | $variable = $event->sender; |
304 | 304 | $variable->set('retour', RetourVariable::class); |
@@ -308,7 +308,7 @@ discard block |
||
308 | 308 | Event::on( |
309 | 309 | Elements::class, |
310 | 310 | Elements::EVENT_BEFORE_SAVE_ELEMENT, |
311 | - function (ElementEvent $event) { |
|
311 | + function(ElementEvent $event) { |
|
312 | 312 | Craft::debug( |
313 | 313 | 'Elements::EVENT_BEFORE_SAVE_ELEMENT', |
314 | 314 | __METHOD__ |
@@ -333,8 +333,8 @@ discard block |
||
333 | 333 | if (strpos($element->uri, '__temp_') === false && !$element->propagating) { |
334 | 334 | // Stash the old URLs by element id, and do so only once, |
335 | 335 | // in case we are called more than once per request |
336 | - if (empty($this->oldElementUris[$element->id])) { |
|
337 | - $this->oldElementUris[$element->id] = $this->getAllElementUris($element); |
|
336 | + if (empty($this->oldElementUris[ $element->id ])) { |
|
337 | + $this->oldElementUris[ $element->id ] = $this->getAllElementUris($element); |
|
338 | 338 | } |
339 | 339 | } |
340 | 340 | } |
@@ -345,7 +345,7 @@ discard block |
||
345 | 345 | Event::on( |
346 | 346 | Elements::class, |
347 | 347 | Elements::EVENT_AFTER_SAVE_ELEMENT, |
348 | - function (ElementEvent $event) { |
|
348 | + function(ElementEvent $event) { |
|
349 | 349 | Craft::debug( |
350 | 350 | 'Elements::EVENT_AFTER_SAVE_ELEMENT', |
351 | 351 | __METHOD__ |
@@ -367,7 +367,7 @@ discard block |
||
367 | 367 | Event::on( |
368 | 368 | Plugins::class, |
369 | 369 | Plugins::EVENT_AFTER_LOAD_PLUGINS, |
370 | - function () { |
|
370 | + function() { |
|
371 | 371 | // Install these only after all other plugins have loaded |
372 | 372 | $request = Craft::$app->getRequest(); |
373 | 373 | // Only respond to non-console site requests |
@@ -385,26 +385,26 @@ discard block |
||
385 | 385 | Event::on( |
386 | 386 | Gql::class, |
387 | 387 | Gql::EVENT_REGISTER_GQL_TYPES, |
388 | - function (RegisterGqlTypesEvent $event) { |
|
388 | + function(RegisterGqlTypesEvent $event) { |
|
389 | 389 | Craft::debug( |
390 | 390 | 'Gql::EVENT_REGISTER_GQL_TYPES', |
391 | 391 | __METHOD__ |
392 | 392 | ); |
393 | - $event->types[] = RetourInterface::class; |
|
393 | + $event->types[ ] = RetourInterface::class; |
|
394 | 394 | } |
395 | 395 | ); |
396 | 396 | // Handler: Gql::EVENT_REGISTER_GQL_QUERIES |
397 | 397 | Event::on( |
398 | 398 | Gql::class, |
399 | 399 | Gql::EVENT_REGISTER_GQL_QUERIES, |
400 | - function (RegisterGqlQueriesEvent $event) { |
|
400 | + function(RegisterGqlQueriesEvent $event) { |
|
401 | 401 | Craft::debug( |
402 | 402 | 'Gql::EVENT_REGISTER_GQL_QUERIES', |
403 | 403 | __METHOD__ |
404 | 404 | ); |
405 | 405 | $queries = RetourQuery::getQueries(); |
406 | 406 | foreach ($queries as $key => $value) { |
407 | - $event->queries[$key] = $value; |
|
407 | + $event->queries[ $key ] = $value; |
|
408 | 408 | } |
409 | 409 | } |
410 | 410 | ); |
@@ -414,7 +414,7 @@ discard block |
||
414 | 414 | Event::on( |
415 | 415 | Schema::class, |
416 | 416 | AlterSchemaFields::EVENT, |
417 | - [GetCraftQLSchema::class, 'handle'] |
|
417 | + [ GetCraftQLSchema::class, 'handle' ] |
|
418 | 418 | ); |
419 | 419 | } |
420 | 420 | } |
@@ -428,7 +428,7 @@ discard block |
||
428 | 428 | Event::on( |
429 | 429 | UrlManager::class, |
430 | 430 | UrlManager::EVENT_REGISTER_SITE_URL_RULES, |
431 | - function (RegisterUrlRulesEvent $event) { |
|
431 | + function(RegisterUrlRulesEvent $event) { |
|
432 | 432 | Craft::debug( |
433 | 433 | 'UrlManager::EVENT_REGISTER_SITE_URL_RULES', |
434 | 434 | __METHOD__ |
@@ -451,15 +451,15 @@ discard block |
||
451 | 451 | Event::on( |
452 | 452 | Dashboard::class, |
453 | 453 | Dashboard::EVENT_REGISTER_WIDGET_TYPES, |
454 | - function (RegisterComponentTypesEvent $event) { |
|
455 | - $event->types[] = RetourWidget::class; |
|
454 | + function(RegisterComponentTypesEvent $event) { |
|
455 | + $event->types[ ] = RetourWidget::class; |
|
456 | 456 | } |
457 | 457 | ); |
458 | 458 | // Handler: UrlManager::EVENT_REGISTER_CP_URL_RULES |
459 | 459 | Event::on( |
460 | 460 | UrlManager::class, |
461 | 461 | UrlManager::EVENT_REGISTER_CP_URL_RULES, |
462 | - function (RegisterUrlRulesEvent $event) { |
|
462 | + function(RegisterUrlRulesEvent $event) { |
|
463 | 463 | Craft::debug( |
464 | 464 | 'UrlManager::EVENT_REGISTER_CP_URL_RULES', |
465 | 465 | __METHOD__ |
@@ -475,13 +475,13 @@ discard block |
||
475 | 475 | Event::on( |
476 | 476 | UserPermissions::class, |
477 | 477 | UserPermissions::EVENT_REGISTER_PERMISSIONS, |
478 | - function (RegisterUserPermissionsEvent $event) { |
|
478 | + function(RegisterUserPermissionsEvent $event) { |
|
479 | 479 | Craft::debug( |
480 | 480 | 'UserPermissions::EVENT_REGISTER_PERMISSIONS', |
481 | 481 | __METHOD__ |
482 | 482 | ); |
483 | 483 | // Register our custom permissions |
484 | - $event->permissions[Craft::t('retour', 'Retour')] = $this->customAdminCpPermissions(); |
|
484 | + $event->permissions[ Craft::t('retour', 'Retour') ] = $this->customAdminCpPermissions(); |
|
485 | 485 | } |
486 | 486 | ); |
487 | 487 | } |
@@ -497,7 +497,7 @@ discard block |
||
497 | 497 | Event::on( |
498 | 498 | ErrorHandler::class, |
499 | 499 | ErrorHandler::EVENT_BEFORE_HANDLE_EXCEPTION, |
500 | - function (ExceptionEvent $event) { |
|
500 | + function(ExceptionEvent $event) { |
|
501 | 501 | Craft::debug( |
502 | 502 | 'ErrorHandler::EVENT_BEFORE_HANDLE_EXCEPTION', |
503 | 503 | __METHOD__ |
@@ -540,16 +540,16 @@ discard block |
||
540 | 540 | protected function handleElementUriChange(Element $element) |
541 | 541 | { |
542 | 542 | $uris = $this->getAllElementUris($element); |
543 | - if (!empty($this->oldElementUris[$element->id])) { |
|
544 | - $oldElementUris = $this->oldElementUris[$element->id]; |
|
543 | + if (!empty($this->oldElementUris[ $element->id ])) { |
|
544 | + $oldElementUris = $this->oldElementUris[ $element->id ]; |
|
545 | 545 | foreach ($uris as $siteId => $newUri) { |
546 | - if (!empty($oldElementUris[$siteId])) { |
|
547 | - $oldUri = $oldElementUris[$siteId]; |
|
546 | + if (!empty($oldElementUris[ $siteId ])) { |
|
547 | + $oldUri = $oldElementUris[ $siteId ]; |
|
548 | 548 | Craft::debug( |
549 | 549 | Craft::t( |
550 | 550 | 'retour', |
551 | 551 | 'Comparing old: {oldUri} to new: {newUri}', |
552 | - ['oldUri' => print_r($oldUri, true), 'newUri' => print_r($newUri, true)] |
|
552 | + [ 'oldUri' => print_r($oldUri, true), 'newUri' => print_r($newUri, true) ] |
|
553 | 553 | ), |
554 | 554 | __METHOD__ |
555 | 555 | ); |
@@ -569,7 +569,7 @@ discard block |
||
569 | 569 | if (self::$settings->uriChangeRedirectSrcMatch === 'fullurl') { |
570 | 570 | try { |
571 | 571 | if ($redirectSiteId !== null) { |
572 | - $redirectSiteId = (int)$redirectSiteId; |
|
572 | + $redirectSiteId = (int) $redirectSiteId; |
|
573 | 573 | } |
574 | 574 | $oldUri = UrlHelper::siteUrl($oldUri, null, null, $redirectSiteId); |
575 | 575 | $newUri = UrlHelper::siteUrl($newUri, null, null, $redirectSiteId); |
@@ -602,13 +602,13 @@ discard block |
||
602 | 602 | */ |
603 | 603 | protected function getAllElementUris(Element $element): array |
604 | 604 | { |
605 | - $uris = []; |
|
605 | + $uris = [ ]; |
|
606 | 606 | if (!self::$craft32 || !ElementHelper::isDraftOrRevision($element)) { |
607 | 607 | $sites = Craft::$app->getSites()->getAllSites(); |
608 | 608 | foreach ($sites as $site) { |
609 | 609 | $uri = Craft::$app->getElements()->getElementUriForSite($element->id, $site->id); |
610 | 610 | if ($uri !== null) { |
611 | - $uris[$site->id] = $uri; |
|
611 | + $uris[ $site->id ] = $uri; |
|
612 | 612 | } |
613 | 613 | } |
614 | 614 | } |
@@ -617,7 +617,7 @@ discard block |
||
617 | 617 | Craft::t( |
618 | 618 | 'retour', |
619 | 619 | 'Getting Element URIs: {uris}', |
620 | - ['uris' => print_r($uris, true)] |
|
620 | + [ 'uris' => print_r($uris, true) ] |
|
621 | 621 | ), |
622 | 622 | __METHOD__ |
623 | 623 | ); |
@@ -672,7 +672,7 @@ discard block |
||
672 | 672 | [ |
673 | 673 | 'key' => 'retour-redirect-caches', |
674 | 674 | 'label' => Craft::t('retour', 'Retour redirect caches'), |
675 | - 'action' => [self::$plugin->redirects, 'invalidateCaches'], |
|
675 | + 'action' => [ self::$plugin->redirects, 'invalidateCaches' ], |
|
676 | 676 | ], |
677 | 677 | ]; |
678 | 678 | } |
@@ -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 |
@@ -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 | - 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 | $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.")); |
@@ -71,12 +71,12 @@ discard block |
||
71 | 71 | if ($legacyModule === null) { |
72 | 72 | return ''; |
73 | 73 | } |
74 | - $lines = []; |
|
74 | + $lines = [ ]; |
|
75 | 75 | if ($async) { |
76 | - $lines[] = "<link rel=\"preload\" href=\"{$legacyModule}\" as=\"style\" onload=\"this.onload=null;this.rel='stylesheet'\" />"; |
|
77 | - $lines[] = "<noscript><link rel=\"stylesheet\" href=\"{$legacyModule}\"></noscript>"; |
|
76 | + $lines[ ] = "<link rel=\"preload\" href=\"{$legacyModule}\" as=\"style\" onload=\"this.onload=null;this.rel='stylesheet'\" />"; |
|
77 | + $lines[ ] = "<noscript><link rel=\"stylesheet\" href=\"{$legacyModule}\"></noscript>"; |
|
78 | 78 | } else { |
79 | - $lines[] = "<link rel=\"stylesheet\" href=\"{$legacyModule}\" />"; |
|
79 | + $lines[ ] = "<link rel=\"stylesheet\" href=\"{$legacyModule}\" />"; |
|
80 | 80 | } |
81 | 81 | |
82 | 82 | return implode("\r\n", $lines); |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | { |
92 | 92 | $result = self::getFile($path); |
93 | 93 | if ($result) { |
94 | - $result = "<style>\r\n".$result."</style>\r\n"; |
|
94 | + $result = "<style>\r\n" . $result . "</style>\r\n"; |
|
95 | 95 | return $result; |
96 | 96 | } |
97 | 97 | |
@@ -134,12 +134,12 @@ discard block |
||
134 | 134 | return ''; |
135 | 135 | } |
136 | 136 | } |
137 | - $lines = []; |
|
137 | + $lines = [ ]; |
|
138 | 138 | if ($async) { |
139 | - $lines[] = "<script type=\"module\" src=\"{$modernModule}\"></script>"; |
|
140 | - $lines[] = "<script nomodule src=\"{$legacyModule}\"></script>"; |
|
139 | + $lines[ ] = "<script type=\"module\" src=\"{$modernModule}\"></script>"; |
|
140 | + $lines[ ] = "<script nomodule src=\"{$legacyModule}\"></script>"; |
|
141 | 141 | } else { |
142 | - $lines[] = "<script src=\"{$legacyModule}\"></script>"; |
|
142 | + $lines[ ] = "<script src=\"{$legacyModule}\"></script>"; |
|
143 | 143 | } |
144 | 144 | |
145 | 145 | return implode("\r\n", $lines); |
@@ -190,8 +190,8 @@ discard block |
||
190 | 190 | $module = self::getModuleEntry($config, $moduleName, $type, $soft); |
191 | 191 | if ($module !== null) { |
192 | 192 | $prefix = self::$isHot |
193 | - ? $config['devServer']['publicPath'] |
|
194 | - : $config['server']['publicPath']; |
|
193 | + ? $config[ 'devServer' ][ 'publicPath' ] |
|
194 | + : $config[ 'server' ][ 'publicPath' ]; |
|
195 | 195 | // If the module isn't a full URL, prefix it |
196 | 196 | if (!UrlHelper::isAbsoluteUrl($module)) { |
197 | 197 | $module = self::combinePaths($prefix, $module); |
@@ -232,19 +232,19 @@ discard block |
||
232 | 232 | $manifest = self::getManifestFile($config, $type); |
233 | 233 | if ($manifest !== null) { |
234 | 234 | // Make sure it exists in the manifest |
235 | - if (empty($manifest[$moduleName])) { |
|
235 | + if (empty($manifest[ $moduleName ])) { |
|
236 | 236 | // Don't report errors for any files in SUPPRESS_ERRORS_FOR_MODULES |
237 | 237 | if (!in_array($moduleName, self::SUPPRESS_ERRORS_FOR_MODULES)) { |
238 | 238 | self::reportError(Craft::t( |
239 | 239 | 'retour', |
240 | 240 | 'Module does not exist in the manifest: {moduleName}', |
241 | - ['moduleName' => $moduleName] |
|
241 | + [ 'moduleName' => $moduleName ] |
|
242 | 242 | ), $soft); |
243 | 243 | } |
244 | 244 | |
245 | 245 | return null; |
246 | 246 | } |
247 | - $module = $manifest[$moduleName]; |
|
247 | + $module = $manifest[ $moduleName ]; |
|
248 | 248 | } |
249 | 249 | |
250 | 250 | return $module; |
@@ -264,14 +264,14 @@ discard block |
||
264 | 264 | $manifest = null; |
265 | 265 | // Determine whether we should use the devServer for HMR or not |
266 | 266 | $devMode = Craft::$app->getConfig()->getGeneral()->devMode; |
267 | - self::$isHot = ($devMode && $config['useDevServer']); |
|
267 | + self::$isHot = ($devMode && $config[ 'useDevServer' ]); |
|
268 | 268 | // Try to get the manifest |
269 | 269 | while ($manifest === null) { |
270 | 270 | $manifestPath = self::$isHot |
271 | - ? $config['devServer']['manifestPath'] |
|
272 | - : $config['server']['manifestPath']; |
|
271 | + ? $config[ 'devServer' ][ 'manifestPath' ] |
|
272 | + : $config[ 'server' ][ 'manifestPath' ]; |
|
273 | 273 | // Normalize the path |
274 | - $path = self::combinePaths($manifestPath, $config['manifest'][$type]); |
|
274 | + $path = self::combinePaths($manifestPath, $config[ 'manifest' ][ $type ]); |
|
275 | 275 | $manifest = self::getJsonFile($path); |
276 | 276 | // If the manifest isn't found, and it was hot, fall back on non-hot |
277 | 277 | if ($manifest === null) { |
@@ -279,7 +279,7 @@ discard block |
||
279 | 279 | self::reportError(Craft::t( |
280 | 280 | 'retour', |
281 | 281 | 'Manifest file not found at: {manifestPath}', |
282 | - ['manifestPath' => $manifestPath] |
|
282 | + [ 'manifestPath' => $manifestPath ] |
|
283 | 283 | ), true); |
284 | 284 | if (self::$isHot) { |
285 | 285 | // Try again, but not with home module replacement |
@@ -322,7 +322,7 @@ discard block |
||
322 | 322 | } |
323 | 323 | if ($path !== null) { |
324 | 324 | $path = self::combinePaths( |
325 | - $config['localFiles']['basePath'], |
|
325 | + $config[ 'localFiles' ][ 'basePath' ], |
|
326 | 326 | $path |
327 | 327 | ); |
328 | 328 | |
@@ -341,7 +341,7 @@ discard block |
||
341 | 341 | */ |
342 | 342 | protected static function getJsonFile(string $path) |
343 | 343 | { |
344 | - return self::getFileFromUri($path, [self::class, 'jsonFileDecode']); |
|
344 | + return self::getFileFromUri($path, [ self::class, 'jsonFileDecode' ]); |
|
345 | 345 | } |
346 | 346 | |
347 | 347 | /** |
@@ -395,14 +395,14 @@ discard block |
||
395 | 395 | protected static function getFileContents(string $path, callable $callback = null) |
396 | 396 | { |
397 | 397 | // Return the memoized manifest if it exists |
398 | - if (!empty(self::$files[$path])) { |
|
399 | - return self::$files[$path]; |
|
398 | + if (!empty(self::$files[ $path ])) { |
|
399 | + return self::$files[ $path ]; |
|
400 | 400 | } |
401 | 401 | // Create the dependency tags |
402 | 402 | $dependency = new TagDependency([ |
403 | 403 | 'tags' => [ |
404 | 404 | self::CACHE_TAG, |
405 | - self::CACHE_TAG.$path, |
|
405 | + self::CACHE_TAG . $path, |
|
406 | 406 | ], |
407 | 407 | ]); |
408 | 408 | // Set the cache duration based on devMode |
@@ -412,8 +412,8 @@ discard block |
||
412 | 412 | // Get the result from the cache, or parse the file |
413 | 413 | $cache = Craft::$app->getCache(); |
414 | 414 | $file = $cache->getOrSet( |
415 | - self::CACHE_KEY.$path, |
|
416 | - function () use ($path, $callback) { |
|
415 | + self::CACHE_KEY . $path, |
|
416 | + function() use ($path, $callback) { |
|
417 | 417 | $result = null; |
418 | 418 | $contents = @file_get_contents($path); |
419 | 419 | if ($contents) { |
@@ -428,7 +428,7 @@ discard block |
||
428 | 428 | $cacheDuration, |
429 | 429 | $dependency |
430 | 430 | ); |
431 | - self::$files[$path] = $file; |
|
431 | + self::$files[ $path ] = $file; |
|
432 | 432 | |
433 | 433 | return $file; |
434 | 434 | } |
@@ -443,7 +443,7 @@ discard block |
||
443 | 443 | protected static function combinePaths(string ...$paths): string |
444 | 444 | { |
445 | 445 | $last_key = \count($paths) - 1; |
446 | - array_walk($paths, function (&$val, $key) use ($last_key) { |
|
446 | + array_walk($paths, function(&$val, $key) use ($last_key) { |
|
447 | 447 | switch ($key) { |
448 | 448 | case 0: |
449 | 449 | $val = rtrim($val, '/ '); |
@@ -461,7 +461,7 @@ discard block |
||
461 | 461 | $last = array_pop($paths); |
462 | 462 | $paths = array_filter($paths); |
463 | 463 | array_unshift($paths, $first); |
464 | - $paths[] = $last; |
|
464 | + $paths[ ] = $last; |
|
465 | 465 | |
466 | 466 | return implode('/', $paths); |
467 | 467 | } |