@@ -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 | } |
@@ -120,9 +120,9 @@ discard block |
||
120 | 120 | /** |
121 | 121 | * @inheritdoc |
122 | 122 | */ |
123 | - public function __construct($id, $parent = null, array $config = []) |
|
123 | + public function __construct($id, $parent = null, array $config = [ ]) |
|
124 | 124 | { |
125 | - $config['components'] = [ |
|
125 | + $config[ 'components' ] = [ |
|
126 | 126 | 'redirects' => Redirects::class, |
127 | 127 | 'statistics' => Statistics::class, |
128 | 128 | // Register the manifest service |
@@ -158,7 +158,7 @@ discard block |
||
158 | 158 | /** |
159 | 159 | * @var array The URIs for the element before it was saved |
160 | 160 | */ |
161 | - public $oldElementUris = []; |
|
161 | + public $oldElementUris = [ ]; |
|
162 | 162 | |
163 | 163 | // Public Methods |
164 | 164 | // ========================================================================= |
@@ -191,7 +191,7 @@ discard block |
||
191 | 191 | Craft::t( |
192 | 192 | 'retour', |
193 | 193 | '{name} plugin loaded', |
194 | - ['name' => $this->name] |
|
194 | + [ 'name' => $this->name ] |
|
195 | 195 | ), |
196 | 196 | __METHOD__ |
197 | 197 | ); |
@@ -211,18 +211,18 @@ discard block |
||
211 | 211 | */ |
212 | 212 | public function getCpNavItem() |
213 | 213 | { |
214 | - $subNavs = []; |
|
214 | + $subNavs = [ ]; |
|
215 | 215 | $navItem = parent::getCpNavItem(); |
216 | 216 | $currentUser = Craft::$app->getUser()->getIdentity(); |
217 | 217 | // Only show sub-navs the user has permission to view |
218 | 218 | if ($currentUser->can('retour:dashboard')) { |
219 | - $subNavs['dashboard'] = [ |
|
219 | + $subNavs[ 'dashboard' ] = [ |
|
220 | 220 | 'label' => 'Dashboard', |
221 | 221 | 'url' => 'retour/dashboard', |
222 | 222 | ]; |
223 | 223 | } |
224 | 224 | if ($currentUser->can('retour:redirects')) { |
225 | - $subNavs['redirects'] = [ |
|
225 | + $subNavs[ 'redirects' ] = [ |
|
226 | 226 | 'label' => 'Redirects', |
227 | 227 | 'url' => 'retour/redirects', |
228 | 228 | ]; |
@@ -233,7 +233,7 @@ discard block |
||
233 | 233 | $editableSettings = false; |
234 | 234 | } |
235 | 235 | if ($currentUser->can('retour:settings') && $editableSettings) { |
236 | - $subNavs['settings'] = [ |
|
236 | + $subNavs[ 'settings' ] = [ |
|
237 | 237 | 'label' => 'Settings', |
238 | 238 | 'url' => 'retour/settings', |
239 | 239 | ]; |
@@ -244,7 +244,7 @@ discard block |
||
244 | 244 | } |
245 | 245 | // A single sub nav item is redundant |
246 | 246 | if (count($subNavs) === 1) { |
247 | - $subNavs = []; |
|
247 | + $subNavs = [ ]; |
|
248 | 248 | } |
249 | 249 | $navItem = array_merge($navItem, [ |
250 | 250 | 'subnav' => $subNavs, |
@@ -300,7 +300,7 @@ discard block |
||
300 | 300 | Event::on( |
301 | 301 | ClearCaches::class, |
302 | 302 | ClearCaches::EVENT_REGISTER_CACHE_OPTIONS, |
303 | - function (RegisterCacheOptionsEvent $event) { |
|
303 | + function(RegisterCacheOptionsEvent $event) { |
|
304 | 304 | Craft::debug( |
305 | 305 | 'ClearCaches::EVENT_REGISTER_CACHE_OPTIONS', |
306 | 306 | __METHOD__ |
@@ -316,7 +316,7 @@ discard block |
||
316 | 316 | Event::on( |
317 | 317 | Plugins::class, |
318 | 318 | Plugins::EVENT_AFTER_INSTALL_PLUGIN, |
319 | - function (PluginEvent $event) { |
|
319 | + function(PluginEvent $event) { |
|
320 | 320 | if ($event->plugin === $this) { |
321 | 321 | // Invalidate our caches after we've been installed |
322 | 322 | $this->clearAllCaches(); |
@@ -343,7 +343,7 @@ discard block |
||
343 | 343 | Event::on( |
344 | 344 | CraftVariable::class, |
345 | 345 | CraftVariable::EVENT_INIT, |
346 | - function (Event $event) { |
|
346 | + function(Event $event) { |
|
347 | 347 | /** @var CraftVariable $variable */ |
348 | 348 | $variable = $event->sender; |
349 | 349 | $variable->set('retour', [ |
@@ -356,7 +356,7 @@ discard block |
||
356 | 356 | Event::on( |
357 | 357 | Elements::class, |
358 | 358 | Elements::EVENT_BEFORE_SAVE_ELEMENT, |
359 | - function (ElementEvent $event) { |
|
359 | + function(ElementEvent $event) { |
|
360 | 360 | Craft::debug( |
361 | 361 | 'Elements::EVENT_BEFORE_SAVE_ELEMENT', |
362 | 362 | __METHOD__ |
@@ -379,8 +379,8 @@ discard block |
||
379 | 379 | if (strpos($element->uri, '__temp_') === false && !$element->propagating) { |
380 | 380 | // Stash the old URLs by element id, and do so only once, |
381 | 381 | // in case we are called more than once per request |
382 | - if (empty($this->oldElementUris[$element->id])) { |
|
383 | - $this->oldElementUris[$element->id] = $this->getAllElementUris($element); |
|
382 | + if (empty($this->oldElementUris[ $element->id ])) { |
|
383 | + $this->oldElementUris[ $element->id ] = $this->getAllElementUris($element); |
|
384 | 384 | } |
385 | 385 | } |
386 | 386 | } |
@@ -391,7 +391,7 @@ discard block |
||
391 | 391 | Event::on( |
392 | 392 | Elements::class, |
393 | 393 | Elements::EVENT_AFTER_SAVE_ELEMENT, |
394 | - function (ElementEvent $event) { |
|
394 | + function(ElementEvent $event) { |
|
395 | 395 | Craft::debug( |
396 | 396 | 'Elements::EVENT_AFTER_SAVE_ELEMENT', |
397 | 397 | __METHOD__ |
@@ -413,7 +413,7 @@ discard block |
||
413 | 413 | Event::on( |
414 | 414 | Plugins::class, |
415 | 415 | Plugins::EVENT_AFTER_LOAD_PLUGINS, |
416 | - function () { |
|
416 | + function() { |
|
417 | 417 | // Install these only after all other plugins have loaded |
418 | 418 | $request = Craft::$app->getRequest(); |
419 | 419 | // Only respond to non-console site requests |
@@ -431,26 +431,26 @@ discard block |
||
431 | 431 | Event::on( |
432 | 432 | Gql::class, |
433 | 433 | Gql::EVENT_REGISTER_GQL_TYPES, |
434 | - function (RegisterGqlTypesEvent $event) { |
|
434 | + function(RegisterGqlTypesEvent $event) { |
|
435 | 435 | Craft::debug( |
436 | 436 | 'Gql::EVENT_REGISTER_GQL_TYPES', |
437 | 437 | __METHOD__ |
438 | 438 | ); |
439 | - $event->types[] = RetourInterface::class; |
|
439 | + $event->types[ ] = RetourInterface::class; |
|
440 | 440 | } |
441 | 441 | ); |
442 | 442 | // Handler: Gql::EVENT_REGISTER_GQL_QUERIES |
443 | 443 | Event::on( |
444 | 444 | Gql::class, |
445 | 445 | Gql::EVENT_REGISTER_GQL_QUERIES, |
446 | - function (RegisterGqlQueriesEvent $event) { |
|
446 | + function(RegisterGqlQueriesEvent $event) { |
|
447 | 447 | Craft::debug( |
448 | 448 | 'Gql::EVENT_REGISTER_GQL_QUERIES', |
449 | 449 | __METHOD__ |
450 | 450 | ); |
451 | 451 | $queries = RetourQuery::getQueries(); |
452 | 452 | foreach ($queries as $key => $value) { |
453 | - $event->queries[$key] = $value; |
|
453 | + $event->queries[ $key ] = $value; |
|
454 | 454 | } |
455 | 455 | } |
456 | 456 | ); |
@@ -458,13 +458,13 @@ discard block |
||
458 | 458 | Event::on( |
459 | 459 | Gql::class, |
460 | 460 | Gql::EVENT_REGISTER_GQL_SCHEMA_COMPONENTS, |
461 | - function (RegisterGqlSchemaComponentsEvent $event) { |
|
461 | + function(RegisterGqlSchemaComponentsEvent $event) { |
|
462 | 462 | Craft::debug( |
463 | 463 | 'Gql::EVENT_REGISTER_GQL_SCHEMA_COMPONENTS', |
464 | 464 | __METHOD__ |
465 | 465 | ); |
466 | 466 | $label = Craft::t('retour', 'Retour'); |
467 | - $event->queries[$label]['retour.all:read'] = ['label' => Craft::t('retour', 'Query Retour data')]; |
|
467 | + $event->queries[ $label ][ 'retour.all:read' ] = [ 'label' => Craft::t('retour', 'Query Retour data') ]; |
|
468 | 468 | } |
469 | 469 | ); |
470 | 470 | } |
@@ -473,7 +473,7 @@ discard block |
||
473 | 473 | Event::on( |
474 | 474 | Schema::class, |
475 | 475 | AlterSchemaFields::EVENT, |
476 | - [GetCraftQLSchema::class, 'handle'] |
|
476 | + [ GetCraftQLSchema::class, 'handle' ] |
|
477 | 477 | ); |
478 | 478 | } |
479 | 479 | } |
@@ -487,7 +487,7 @@ discard block |
||
487 | 487 | Event::on( |
488 | 488 | UrlManager::class, |
489 | 489 | UrlManager::EVENT_REGISTER_SITE_URL_RULES, |
490 | - function (RegisterUrlRulesEvent $event) { |
|
490 | + function(RegisterUrlRulesEvent $event) { |
|
491 | 491 | Craft::debug( |
492 | 492 | 'UrlManager::EVENT_REGISTER_SITE_URL_RULES', |
493 | 493 | __METHOD__ |
@@ -510,15 +510,15 @@ discard block |
||
510 | 510 | Event::on( |
511 | 511 | Dashboard::class, |
512 | 512 | Dashboard::EVENT_REGISTER_WIDGET_TYPES, |
513 | - function (RegisterComponentTypesEvent $event) { |
|
514 | - $event->types[] = RetourWidget::class; |
|
513 | + function(RegisterComponentTypesEvent $event) { |
|
514 | + $event->types[ ] = RetourWidget::class; |
|
515 | 515 | } |
516 | 516 | ); |
517 | 517 | // Handler: UrlManager::EVENT_REGISTER_CP_URL_RULES |
518 | 518 | Event::on( |
519 | 519 | UrlManager::class, |
520 | 520 | UrlManager::EVENT_REGISTER_CP_URL_RULES, |
521 | - function (RegisterUrlRulesEvent $event) { |
|
521 | + function(RegisterUrlRulesEvent $event) { |
|
522 | 522 | Craft::debug( |
523 | 523 | 'UrlManager::EVENT_REGISTER_CP_URL_RULES', |
524 | 524 | __METHOD__ |
@@ -534,13 +534,13 @@ discard block |
||
534 | 534 | Event::on( |
535 | 535 | UserPermissions::class, |
536 | 536 | UserPermissions::EVENT_REGISTER_PERMISSIONS, |
537 | - function (RegisterUserPermissionsEvent $event) { |
|
537 | + function(RegisterUserPermissionsEvent $event) { |
|
538 | 538 | Craft::debug( |
539 | 539 | 'UserPermissions::EVENT_REGISTER_PERMISSIONS', |
540 | 540 | __METHOD__ |
541 | 541 | ); |
542 | 542 | // Register our custom permissions |
543 | - $event->permissions[Craft::t('retour', 'Retour')] = $this->customAdminCpPermissions(); |
|
543 | + $event->permissions[ Craft::t('retour', 'Retour') ] = $this->customAdminCpPermissions(); |
|
544 | 544 | } |
545 | 545 | ); |
546 | 546 | } |
@@ -556,7 +556,7 @@ discard block |
||
556 | 556 | Event::on( |
557 | 557 | ErrorHandler::class, |
558 | 558 | ErrorHandler::EVENT_BEFORE_HANDLE_EXCEPTION, |
559 | - function (ExceptionEvent $event) { |
|
559 | + function(ExceptionEvent $event) { |
|
560 | 560 | Craft::debug( |
561 | 561 | 'ErrorHandler::EVENT_BEFORE_HANDLE_EXCEPTION', |
562 | 562 | __METHOD__ |
@@ -599,16 +599,16 @@ discard block |
||
599 | 599 | protected function handleElementUriChange(Element $element) |
600 | 600 | { |
601 | 601 | $uris = $this->getAllElementUris($element); |
602 | - if (!empty($this->oldElementUris[$element->id])) { |
|
603 | - $oldElementUris = $this->oldElementUris[$element->id]; |
|
602 | + if (!empty($this->oldElementUris[ $element->id ])) { |
|
603 | + $oldElementUris = $this->oldElementUris[ $element->id ]; |
|
604 | 604 | foreach ($uris as $siteId => $newUri) { |
605 | - if (!empty($oldElementUris[$siteId])) { |
|
606 | - $oldUri = $oldElementUris[$siteId]; |
|
605 | + if (!empty($oldElementUris[ $siteId ])) { |
|
606 | + $oldUri = $oldElementUris[ $siteId ]; |
|
607 | 607 | Craft::debug( |
608 | 608 | Craft::t( |
609 | 609 | 'retour', |
610 | 610 | 'Comparing old: {oldUri} to new: {newUri}', |
611 | - ['oldUri' => print_r($oldUri, true), 'newUri' => print_r($newUri, true)] |
|
611 | + [ 'oldUri' => print_r($oldUri, true), 'newUri' => print_r($newUri, true) ] |
|
612 | 612 | ), |
613 | 613 | __METHOD__ |
614 | 614 | ); |
@@ -628,7 +628,7 @@ discard block |
||
628 | 628 | if (self::$settings->uriChangeRedirectSrcMatch === 'fullurl') { |
629 | 629 | try { |
630 | 630 | if ($redirectSiteId !== null) { |
631 | - $redirectSiteId = (int)$redirectSiteId; |
|
631 | + $redirectSiteId = (int) $redirectSiteId; |
|
632 | 632 | } |
633 | 633 | $oldUri = UrlHelper::siteUrl($oldUri, null, null, $redirectSiteId); |
634 | 634 | $newUri = UrlHelper::siteUrl($newUri, null, null, $redirectSiteId); |
@@ -661,13 +661,13 @@ discard block |
||
661 | 661 | */ |
662 | 662 | protected function getAllElementUris(Element $element): array |
663 | 663 | { |
664 | - $uris = []; |
|
664 | + $uris = [ ]; |
|
665 | 665 | if (!self::$craft32 || !ElementHelper::isDraftOrRevision($element)) { |
666 | 666 | $sites = Craft::$app->getSites()->getAllSites(); |
667 | 667 | foreach ($sites as $site) { |
668 | 668 | $uri = Craft::$app->getElements()->getElementUriForSite($element->id, $site->id); |
669 | 669 | if ($uri !== null) { |
670 | - $uris[$site->id] = $uri; |
|
670 | + $uris[ $site->id ] = $uri; |
|
671 | 671 | } |
672 | 672 | } |
673 | 673 | } |
@@ -676,7 +676,7 @@ discard block |
||
676 | 676 | Craft::t( |
677 | 677 | 'retour', |
678 | 678 | 'Getting Element URIs: {uris}', |
679 | - ['uris' => print_r($uris, true)] |
|
679 | + [ 'uris' => print_r($uris, true) ] |
|
680 | 680 | ), |
681 | 681 | __METHOD__ |
682 | 682 | ); |
@@ -731,7 +731,7 @@ discard block |
||
731 | 731 | [ |
732 | 732 | 'key' => 'retour-redirect-caches', |
733 | 733 | 'label' => Craft::t('retour', 'Retour redirect caches'), |
734 | - 'action' => [self::$plugin->redirects, 'invalidateCaches'], |
|
734 | + 'action' => [ self::$plugin->redirects, 'invalidateCaches' ], |
|
735 | 735 | ], |
736 | 736 | ]; |
737 | 737 | } |
@@ -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 [ |