@@ -125,9 +125,9 @@ discard block |
||
| 125 | 125 | /** |
| 126 | 126 | * @inheritdoc |
| 127 | 127 | */ |
| 128 | - public function __construct($id, $parent = null, array $config = []) |
|
| 128 | + public function __construct($id, $parent = null, array $config = [ ]) |
|
| 129 | 129 | { |
| 130 | - $config['components'] = [ |
|
| 130 | + $config[ 'components' ] = [ |
|
| 131 | 131 | 'redirects' => Redirects::class, |
| 132 | 132 | 'statistics' => Statistics::class, |
| 133 | 133 | // Register the manifest service |
@@ -163,7 +163,7 @@ discard block |
||
| 163 | 163 | /** |
| 164 | 164 | * @var array The URIs for the element before it was saved |
| 165 | 165 | */ |
| 166 | - public $oldElementUris = []; |
|
| 166 | + public $oldElementUris = [ ]; |
|
| 167 | 167 | |
| 168 | 168 | // Public Methods |
| 169 | 169 | // ========================================================================= |
@@ -197,7 +197,7 @@ discard block |
||
| 197 | 197 | Craft::t( |
| 198 | 198 | 'retour', |
| 199 | 199 | '{name} plugin loaded', |
| 200 | - ['name' => $this->name] |
|
| 200 | + [ 'name' => $this->name ] |
|
| 201 | 201 | ), |
| 202 | 202 | __METHOD__ |
| 203 | 203 | ); |
@@ -217,18 +217,18 @@ discard block |
||
| 217 | 217 | */ |
| 218 | 218 | public function getCpNavItem() |
| 219 | 219 | { |
| 220 | - $subNavs = []; |
|
| 220 | + $subNavs = [ ]; |
|
| 221 | 221 | $navItem = parent::getCpNavItem(); |
| 222 | 222 | $currentUser = Craft::$app->getUser()->getIdentity(); |
| 223 | 223 | // Only show sub-navs the user has permission to view |
| 224 | 224 | if ($currentUser->can('retour:dashboard')) { |
| 225 | - $subNavs['dashboard'] = [ |
|
| 225 | + $subNavs[ 'dashboard' ] = [ |
|
| 226 | 226 | 'label' => 'Dashboard', |
| 227 | 227 | 'url' => 'retour/dashboard', |
| 228 | 228 | ]; |
| 229 | 229 | } |
| 230 | 230 | if ($currentUser->can('retour:redirects')) { |
| 231 | - $subNavs['redirects'] = [ |
|
| 231 | + $subNavs[ 'redirects' ] = [ |
|
| 232 | 232 | 'label' => 'Redirects', |
| 233 | 233 | 'url' => 'retour/redirects', |
| 234 | 234 | ]; |
@@ -239,7 +239,7 @@ discard block |
||
| 239 | 239 | $editableSettings = false; |
| 240 | 240 | } |
| 241 | 241 | if ($currentUser->can('retour:settings') && $editableSettings) { |
| 242 | - $subNavs['settings'] = [ |
|
| 242 | + $subNavs[ 'settings' ] = [ |
|
| 243 | 243 | 'label' => 'Settings', |
| 244 | 244 | 'url' => 'retour/settings', |
| 245 | 245 | ]; |
@@ -250,7 +250,7 @@ discard block |
||
| 250 | 250 | } |
| 251 | 251 | // A single sub nav item is redundant |
| 252 | 252 | if (count($subNavs) === 1) { |
| 253 | - $subNavs = []; |
|
| 253 | + $subNavs = [ ]; |
|
| 254 | 254 | } |
| 255 | 255 | $navItem = array_merge($navItem, [ |
| 256 | 256 | 'subnav' => $subNavs, |
@@ -306,7 +306,7 @@ discard block |
||
| 306 | 306 | Event::on( |
| 307 | 307 | ClearCaches::class, |
| 308 | 308 | ClearCaches::EVENT_REGISTER_CACHE_OPTIONS, |
| 309 | - function (RegisterCacheOptionsEvent $event) { |
|
| 309 | + function(RegisterCacheOptionsEvent $event) { |
|
| 310 | 310 | Craft::debug( |
| 311 | 311 | 'ClearCaches::EVENT_REGISTER_CACHE_OPTIONS', |
| 312 | 312 | __METHOD__ |
@@ -322,7 +322,7 @@ discard block |
||
| 322 | 322 | Event::on( |
| 323 | 323 | Plugins::class, |
| 324 | 324 | Plugins::EVENT_AFTER_INSTALL_PLUGIN, |
| 325 | - function (PluginEvent $event) { |
|
| 325 | + function(PluginEvent $event) { |
|
| 326 | 326 | if ($event->plugin === $this) { |
| 327 | 327 | // Invalidate our caches after we've been installed |
| 328 | 328 | $this->clearAllCaches(); |
@@ -349,7 +349,7 @@ discard block |
||
| 349 | 349 | Event::on( |
| 350 | 350 | CraftVariable::class, |
| 351 | 351 | CraftVariable::EVENT_INIT, |
| 352 | - function (Event $event) { |
|
| 352 | + function(Event $event) { |
|
| 353 | 353 | /** @var CraftVariable $variable */ |
| 354 | 354 | $variable = $event->sender; |
| 355 | 355 | $variable->set('retour', [ |
@@ -362,7 +362,7 @@ discard block |
||
| 362 | 362 | Event::on( |
| 363 | 363 | Elements::class, |
| 364 | 364 | Elements::EVENT_BEFORE_SAVE_ELEMENT, |
| 365 | - function (ElementEvent $event) { |
|
| 365 | + function(ElementEvent $event) { |
|
| 366 | 366 | Craft::debug( |
| 367 | 367 | 'Elements::EVENT_BEFORE_SAVE_ELEMENT', |
| 368 | 368 | __METHOD__ |
@@ -385,8 +385,8 @@ discard block |
||
| 385 | 385 | if (strpos($element->uri, '__temp_') === false && !$element->propagating) { |
| 386 | 386 | // Stash the old URLs by element id, and do so only once, |
| 387 | 387 | // in case we are called more than once per request |
| 388 | - if (empty($this->oldElementUris[$element->id])) { |
|
| 389 | - $this->oldElementUris[$element->id] = $this->getAllElementUris($element); |
|
| 388 | + if (empty($this->oldElementUris[ $element->id ])) { |
|
| 389 | + $this->oldElementUris[ $element->id ] = $this->getAllElementUris($element); |
|
| 390 | 390 | } |
| 391 | 391 | } |
| 392 | 392 | } |
@@ -397,7 +397,7 @@ discard block |
||
| 397 | 397 | Event::on( |
| 398 | 398 | Elements::class, |
| 399 | 399 | Elements::EVENT_AFTER_SAVE_ELEMENT, |
| 400 | - function (ElementEvent $event) { |
|
| 400 | + function(ElementEvent $event) { |
|
| 401 | 401 | Craft::debug( |
| 402 | 402 | 'Elements::EVENT_AFTER_SAVE_ELEMENT', |
| 403 | 403 | __METHOD__ |
@@ -419,7 +419,7 @@ discard block |
||
| 419 | 419 | Event::on( |
| 420 | 420 | Plugins::class, |
| 421 | 421 | Plugins::EVENT_AFTER_LOAD_PLUGINS, |
| 422 | - function () { |
|
| 422 | + function() { |
|
| 423 | 423 | // Install these only after all other plugins have loaded |
| 424 | 424 | $request = Craft::$app->getRequest(); |
| 425 | 425 | // Only respond to non-console site requests |
@@ -437,26 +437,26 @@ discard block |
||
| 437 | 437 | Event::on( |
| 438 | 438 | Gql::class, |
| 439 | 439 | Gql::EVENT_REGISTER_GQL_TYPES, |
| 440 | - function (RegisterGqlTypesEvent $event) { |
|
| 440 | + function(RegisterGqlTypesEvent $event) { |
|
| 441 | 441 | Craft::debug( |
| 442 | 442 | 'Gql::EVENT_REGISTER_GQL_TYPES', |
| 443 | 443 | __METHOD__ |
| 444 | 444 | ); |
| 445 | - $event->types[] = RetourInterface::class; |
|
| 445 | + $event->types[ ] = RetourInterface::class; |
|
| 446 | 446 | } |
| 447 | 447 | ); |
| 448 | 448 | // Handler: Gql::EVENT_REGISTER_GQL_QUERIES |
| 449 | 449 | Event::on( |
| 450 | 450 | Gql::class, |
| 451 | 451 | Gql::EVENT_REGISTER_GQL_QUERIES, |
| 452 | - function (RegisterGqlQueriesEvent $event) { |
|
| 452 | + function(RegisterGqlQueriesEvent $event) { |
|
| 453 | 453 | Craft::debug( |
| 454 | 454 | 'Gql::EVENT_REGISTER_GQL_QUERIES', |
| 455 | 455 | __METHOD__ |
| 456 | 456 | ); |
| 457 | 457 | $queries = RetourQuery::getQueries(); |
| 458 | 458 | foreach ($queries as $key => $value) { |
| 459 | - $event->queries[$key] = $value; |
|
| 459 | + $event->queries[ $key ] = $value; |
|
| 460 | 460 | } |
| 461 | 461 | } |
| 462 | 462 | ); |
@@ -465,13 +465,13 @@ discard block |
||
| 465 | 465 | Event::on( |
| 466 | 466 | Gql::class, |
| 467 | 467 | Gql::EVENT_REGISTER_GQL_SCHEMA_COMPONENTS, |
| 468 | - function (RegisterGqlSchemaComponentsEvent $event) { |
|
| 468 | + function(RegisterGqlSchemaComponentsEvent $event) { |
|
| 469 | 469 | Craft::debug( |
| 470 | 470 | 'Gql::EVENT_REGISTER_GQL_SCHEMA_COMPONENTS', |
| 471 | 471 | __METHOD__ |
| 472 | 472 | ); |
| 473 | 473 | $label = Craft::t('retour', 'Retour'); |
| 474 | - $event->queries[$label]['retour.all:read'] = ['label' => Craft::t('retour', 'Query Retour data')]; |
|
| 474 | + $event->queries[ $label ][ 'retour.all:read' ] = [ 'label' => Craft::t('retour', 'Query Retour data') ]; |
|
| 475 | 475 | } |
| 476 | 476 | ); |
| 477 | 477 | } |
@@ -481,7 +481,7 @@ discard block |
||
| 481 | 481 | Event::on( |
| 482 | 482 | Schema::class, |
| 483 | 483 | AlterSchemaFields::EVENT, |
| 484 | - [GetCraftQLSchema::class, 'handle'] |
|
| 484 | + [ GetCraftQLSchema::class, 'handle' ] |
|
| 485 | 485 | ); |
| 486 | 486 | } |
| 487 | 487 | } |
@@ -495,7 +495,7 @@ discard block |
||
| 495 | 495 | Event::on( |
| 496 | 496 | UrlManager::class, |
| 497 | 497 | UrlManager::EVENT_REGISTER_SITE_URL_RULES, |
| 498 | - function (RegisterUrlRulesEvent $event) { |
|
| 498 | + function(RegisterUrlRulesEvent $event) { |
|
| 499 | 499 | Craft::debug( |
| 500 | 500 | 'UrlManager::EVENT_REGISTER_SITE_URL_RULES', |
| 501 | 501 | __METHOD__ |
@@ -518,15 +518,15 @@ discard block |
||
| 518 | 518 | Event::on( |
| 519 | 519 | Dashboard::class, |
| 520 | 520 | Dashboard::EVENT_REGISTER_WIDGET_TYPES, |
| 521 | - function (RegisterComponentTypesEvent $event) { |
|
| 522 | - $event->types[] = RetourWidget::class; |
|
| 521 | + function(RegisterComponentTypesEvent $event) { |
|
| 522 | + $event->types[ ] = RetourWidget::class; |
|
| 523 | 523 | } |
| 524 | 524 | ); |
| 525 | 525 | // Handler: UrlManager::EVENT_REGISTER_CP_URL_RULES |
| 526 | 526 | Event::on( |
| 527 | 527 | UrlManager::class, |
| 528 | 528 | UrlManager::EVENT_REGISTER_CP_URL_RULES, |
| 529 | - function (RegisterUrlRulesEvent $event) { |
|
| 529 | + function(RegisterUrlRulesEvent $event) { |
|
| 530 | 530 | Craft::debug( |
| 531 | 531 | 'UrlManager::EVENT_REGISTER_CP_URL_RULES', |
| 532 | 532 | __METHOD__ |
@@ -542,13 +542,13 @@ discard block |
||
| 542 | 542 | Event::on( |
| 543 | 543 | UserPermissions::class, |
| 544 | 544 | UserPermissions::EVENT_REGISTER_PERMISSIONS, |
| 545 | - function (RegisterUserPermissionsEvent $event) { |
|
| 545 | + function(RegisterUserPermissionsEvent $event) { |
|
| 546 | 546 | Craft::debug( |
| 547 | 547 | 'UserPermissions::EVENT_REGISTER_PERMISSIONS', |
| 548 | 548 | __METHOD__ |
| 549 | 549 | ); |
| 550 | 550 | // Register our custom permissions |
| 551 | - $event->permissions[Craft::t('retour', 'Retour')] = $this->customAdminCpPermissions(); |
|
| 551 | + $event->permissions[ Craft::t('retour', 'Retour') ] = $this->customAdminCpPermissions(); |
|
| 552 | 552 | } |
| 553 | 553 | ); |
| 554 | 554 | } |
@@ -564,7 +564,7 @@ discard block |
||
| 564 | 564 | Event::on( |
| 565 | 565 | ErrorHandler::class, |
| 566 | 566 | ErrorHandler::EVENT_BEFORE_HANDLE_EXCEPTION, |
| 567 | - function (ExceptionEvent $event) { |
|
| 567 | + function(ExceptionEvent $event) { |
|
| 568 | 568 | Craft::debug( |
| 569 | 569 | 'ErrorHandler::EVENT_BEFORE_HANDLE_EXCEPTION', |
| 570 | 570 | __METHOD__ |
@@ -607,16 +607,16 @@ discard block |
||
| 607 | 607 | protected function handleElementUriChange(Element $element) |
| 608 | 608 | { |
| 609 | 609 | $uris = $this->getAllElementUris($element); |
| 610 | - if (!empty($this->oldElementUris[$element->id])) { |
|
| 611 | - $oldElementUris = $this->oldElementUris[$element->id]; |
|
| 610 | + if (!empty($this->oldElementUris[ $element->id ])) { |
|
| 611 | + $oldElementUris = $this->oldElementUris[ $element->id ]; |
|
| 612 | 612 | foreach ($uris as $siteId => $newUri) { |
| 613 | - if (!empty($oldElementUris[$siteId])) { |
|
| 614 | - $oldUri = $oldElementUris[$siteId]; |
|
| 613 | + if (!empty($oldElementUris[ $siteId ])) { |
|
| 614 | + $oldUri = $oldElementUris[ $siteId ]; |
|
| 615 | 615 | Craft::debug( |
| 616 | 616 | Craft::t( |
| 617 | 617 | 'retour', |
| 618 | 618 | 'Comparing old: {oldUri} to new: {newUri}', |
| 619 | - ['oldUri' => print_r($oldUri, true), 'newUri' => print_r($newUri, true)] |
|
| 619 | + [ 'oldUri' => print_r($oldUri, true), 'newUri' => print_r($newUri, true) ] |
|
| 620 | 620 | ), |
| 621 | 621 | __METHOD__ |
| 622 | 622 | ); |
@@ -636,7 +636,7 @@ discard block |
||
| 636 | 636 | if (self::$settings->uriChangeRedirectSrcMatch === 'fullurl') { |
| 637 | 637 | try { |
| 638 | 638 | if ($redirectSiteId !== null) { |
| 639 | - $redirectSiteId = (int)$redirectSiteId; |
|
| 639 | + $redirectSiteId = (int) $redirectSiteId; |
|
| 640 | 640 | } |
| 641 | 641 | $oldUri = UrlHelper::siteUrl($oldUri, null, null, $redirectSiteId); |
| 642 | 642 | $newUri = UrlHelper::siteUrl($newUri, null, null, $redirectSiteId); |
@@ -669,13 +669,13 @@ discard block |
||
| 669 | 669 | */ |
| 670 | 670 | protected function getAllElementUris(Element $element): array |
| 671 | 671 | { |
| 672 | - $uris = []; |
|
| 672 | + $uris = [ ]; |
|
| 673 | 673 | if (!self::$craft32 || !ElementHelper::isDraftOrRevision($element)) { |
| 674 | 674 | $sites = Craft::$app->getSites()->getAllSites(); |
| 675 | 675 | foreach ($sites as $site) { |
| 676 | 676 | $uri = Craft::$app->getElements()->getElementUriForSite($element->id, $site->id); |
| 677 | 677 | if ($uri !== null) { |
| 678 | - $uris[$site->id] = $uri; |
|
| 678 | + $uris[ $site->id ] = $uri; |
|
| 679 | 679 | } |
| 680 | 680 | } |
| 681 | 681 | } |
@@ -684,7 +684,7 @@ discard block |
||
| 684 | 684 | Craft::t( |
| 685 | 685 | 'retour', |
| 686 | 686 | 'Getting Element URIs: {uris}', |
| 687 | - ['uris' => print_r($uris, true)] |
|
| 687 | + [ 'uris' => print_r($uris, true) ] |
|
| 688 | 688 | ), |
| 689 | 689 | __METHOD__ |
| 690 | 690 | ); |
@@ -739,7 +739,7 @@ discard block |
||
| 739 | 739 | [ |
| 740 | 740 | 'key' => 'retour-redirect-caches', |
| 741 | 741 | 'label' => Craft::t('retour', 'Retour redirect caches'), |
| 742 | - 'action' => [self::$plugin->redirects, 'invalidateCaches'], |
|
| 742 | + 'action' => [ self::$plugin->redirects, 'invalidateCaches' ], |
|
| 743 | 743 | ], |
| 744 | 744 | ]; |
| 745 | 745 | } |