@@ -56,7 +56,7 @@ discard block |
||
| 56 | 56 | /** |
| 57 | 57 | * @var array The URIs for the element before it was saved |
| 58 | 58 | */ |
| 59 | - public $oldElementUris = []; |
|
| 59 | + public $oldElementUris = [ ]; |
|
| 60 | 60 | |
| 61 | 61 | // Public Methods |
| 62 | 62 | // ========================================================================= |
@@ -68,8 +68,8 @@ discard block |
||
| 68 | 68 | { |
| 69 | 69 | // Stash the old URLs by element id, and do so only once, |
| 70 | 70 | // in case we are called more than once per request |
| 71 | - if (empty($this->oldElementUris[$element->id])) { |
|
| 72 | - $this->oldElementUris[$element->id] = $this->getAllElementUris($element); |
|
| 71 | + if (empty($this->oldElementUris[ $element->id ])) { |
|
| 72 | + $this->oldElementUris[ $element->id ] = $this->getAllElementUris($element); |
|
| 73 | 73 | } |
| 74 | 74 | } |
| 75 | 75 | |
@@ -79,16 +79,16 @@ discard block |
||
| 79 | 79 | public function handleElementUriChange(Element $element) |
| 80 | 80 | { |
| 81 | 81 | $uris = $this->getAllElementUris($element); |
| 82 | - if (!empty($this->oldElementUris[$element->id])) { |
|
| 83 | - $oldElementUris = $this->oldElementUris[$element->id]; |
|
| 82 | + if (!empty($this->oldElementUris[ $element->id ])) { |
|
| 83 | + $oldElementUris = $this->oldElementUris[ $element->id ]; |
|
| 84 | 84 | foreach ($uris as $siteId => $newUri) { |
| 85 | - if (!empty($oldElementUris[$siteId])) { |
|
| 86 | - $oldUri = $oldElementUris[$siteId]; |
|
| 85 | + if (!empty($oldElementUris[ $siteId ])) { |
|
| 86 | + $oldUri = $oldElementUris[ $siteId ]; |
|
| 87 | 87 | Craft::debug( |
| 88 | 88 | Craft::t( |
| 89 | 89 | 'retour', |
| 90 | 90 | 'Comparing old: {oldUri} to new: {newUri}', |
| 91 | - ['oldUri' => print_r($oldUri, true), 'newUri' => print_r($newUri, true)] |
|
| 91 | + [ 'oldUri' => print_r($oldUri, true), 'newUri' => print_r($newUri, true) ] |
|
| 92 | 92 | ), |
| 93 | 93 | __METHOD__ |
| 94 | 94 | ); |
@@ -108,7 +108,7 @@ discard block |
||
| 108 | 108 | if (Retour::$settings->uriChangeRedirectSrcMatch === 'fullurl') { |
| 109 | 109 | try { |
| 110 | 110 | if ($redirectSiteId !== null) { |
| 111 | - $redirectSiteId = (int)$redirectSiteId; |
|
| 111 | + $redirectSiteId = (int) $redirectSiteId; |
|
| 112 | 112 | } |
| 113 | 113 | $oldUri = \craft\helpers\UrlHelper::siteUrl($oldUri, null, null, $redirectSiteId); |
| 114 | 114 | $newUri = UrlHelper::siteUrl($newUri, null, null, $redirectSiteId); |
@@ -126,14 +126,14 @@ discard block |
||
| 126 | 126 | 'siteId' => $redirectSiteId, |
| 127 | 127 | ]; |
| 128 | 128 | // Trigger a 'beforeSaveEntryRedirect' event |
| 129 | - $isNew = (int)$redirectConfig['id'] === 0; |
|
| 129 | + $isNew = (int) $redirectConfig[ 'id' ] === 0; |
|
| 130 | 130 | $event = new RedirectEvent([ |
| 131 | 131 | 'isNew' => $isNew, |
| 132 | - 'legacyUrl' => $redirectConfig['redirectSrcUrlParsed'], |
|
| 133 | - 'destinationUrl' => $redirectConfig['redirectDestUrl'], |
|
| 134 | - 'matchType' => $redirectConfig['redirectSrcMatch'], |
|
| 135 | - 'redirectType' => $redirectConfig['redirectHttpCode'], |
|
| 136 | - 'siteId' => $redirectConfig['siteId'], |
|
| 132 | + 'legacyUrl' => $redirectConfig[ 'redirectSrcUrlParsed' ], |
|
| 133 | + 'destinationUrl' => $redirectConfig[ 'redirectDestUrl' ], |
|
| 134 | + 'matchType' => $redirectConfig[ 'redirectSrcMatch' ], |
|
| 135 | + 'redirectType' => $redirectConfig[ 'redirectHttpCode' ], |
|
| 136 | + 'siteId' => $redirectConfig[ 'siteId' ], |
|
| 137 | 137 | ]); |
| 138 | 138 | $this->trigger(self::EVENT_BEFORE_SAVE_ENTRY_REDIRECT, $event); |
| 139 | 139 | if (!$event->isValid) { |
@@ -155,13 +155,13 @@ discard block |
||
| 155 | 155 | */ |
| 156 | 156 | protected function getAllElementUris(Element $element): array |
| 157 | 157 | { |
| 158 | - $uris = []; |
|
| 158 | + $uris = [ ]; |
|
| 159 | 159 | if (!Retour::$craft32 || !ElementHelper::isDraftOrRevision($element)) { |
| 160 | 160 | $sites = Craft::$app->getSites()->getAllSites(); |
| 161 | 161 | foreach ($sites as $site) { |
| 162 | 162 | $uri = Craft::$app->getElements()->getElementUriForSite($element->id, $site->id); |
| 163 | 163 | if ($uri !== null) { |
| 164 | - $uris[$site->id] = $uri; |
|
| 164 | + $uris[ $site->id ] = $uri; |
|
| 165 | 165 | } |
| 166 | 166 | } |
| 167 | 167 | } |
@@ -170,7 +170,7 @@ discard block |
||
| 170 | 170 | Craft::t( |
| 171 | 171 | 'retour', |
| 172 | 172 | 'Getting Element URIs: {uris}', |
| 173 | - ['uris' => print_r($uris, true)] |
|
| 173 | + [ 'uris' => print_r($uris, true) ] |
|
| 174 | 174 | ), |
| 175 | 175 | __METHOD__ |
| 176 | 176 | ); |
@@ -126,9 +126,9 @@ discard block |
||
| 126 | 126 | /** |
| 127 | 127 | * @inheritdoc |
| 128 | 128 | */ |
| 129 | - public function __construct($id, $parent = null, array $config = []) |
|
| 129 | + public function __construct($id, $parent = null, array $config = [ ]) |
|
| 130 | 130 | { |
| 131 | - $config['components'] = [ |
|
| 131 | + $config[ 'components' ] = [ |
|
| 132 | 132 | 'events' => Events::class, |
| 133 | 133 | 'redirects' => Redirects::class, |
| 134 | 134 | 'statistics' => Statistics::class, |
@@ -194,7 +194,7 @@ discard block |
||
| 194 | 194 | Craft::t( |
| 195 | 195 | 'retour', |
| 196 | 196 | '{name} plugin loaded', |
| 197 | - ['name' => $this->name] |
|
| 197 | + [ 'name' => $this->name ] |
|
| 198 | 198 | ), |
| 199 | 199 | __METHOD__ |
| 200 | 200 | ); |
@@ -214,18 +214,18 @@ discard block |
||
| 214 | 214 | */ |
| 215 | 215 | public function getCpNavItem() |
| 216 | 216 | { |
| 217 | - $subNavs = []; |
|
| 217 | + $subNavs = [ ]; |
|
| 218 | 218 | $navItem = parent::getCpNavItem(); |
| 219 | 219 | $currentUser = Craft::$app->getUser()->getIdentity(); |
| 220 | 220 | // Only show sub-navs the user has permission to view |
| 221 | 221 | if ($currentUser->can('retour:dashboard')) { |
| 222 | - $subNavs['dashboard'] = [ |
|
| 222 | + $subNavs[ 'dashboard' ] = [ |
|
| 223 | 223 | 'label' => 'Dashboard', |
| 224 | 224 | 'url' => 'retour/dashboard', |
| 225 | 225 | ]; |
| 226 | 226 | } |
| 227 | 227 | if ($currentUser->can('retour:redirects')) { |
| 228 | - $subNavs['redirects'] = [ |
|
| 228 | + $subNavs[ 'redirects' ] = [ |
|
| 229 | 229 | 'label' => 'Redirects', |
| 230 | 230 | 'url' => 'retour/redirects', |
| 231 | 231 | ]; |
@@ -236,7 +236,7 @@ discard block |
||
| 236 | 236 | $editableSettings = false; |
| 237 | 237 | } |
| 238 | 238 | if ($currentUser->can('retour:settings') && $editableSettings) { |
| 239 | - $subNavs['settings'] = [ |
|
| 239 | + $subNavs[ 'settings' ] = [ |
|
| 240 | 240 | 'label' => 'Settings', |
| 241 | 241 | 'url' => 'retour/settings', |
| 242 | 242 | ]; |
@@ -247,7 +247,7 @@ discard block |
||
| 247 | 247 | } |
| 248 | 248 | // A single sub nav item is redundant |
| 249 | 249 | if (count($subNavs) === 1) { |
| 250 | - $subNavs = []; |
|
| 250 | + $subNavs = [ ]; |
|
| 251 | 251 | } |
| 252 | 252 | $navItem = array_merge($navItem, [ |
| 253 | 253 | 'subnav' => $subNavs, |
@@ -303,7 +303,7 @@ discard block |
||
| 303 | 303 | Event::on( |
| 304 | 304 | ClearCaches::class, |
| 305 | 305 | ClearCaches::EVENT_REGISTER_CACHE_OPTIONS, |
| 306 | - function (RegisterCacheOptionsEvent $event) { |
|
| 306 | + function(RegisterCacheOptionsEvent $event) { |
|
| 307 | 307 | Craft::debug( |
| 308 | 308 | 'ClearCaches::EVENT_REGISTER_CACHE_OPTIONS', |
| 309 | 309 | __METHOD__ |
@@ -319,7 +319,7 @@ discard block |
||
| 319 | 319 | Event::on( |
| 320 | 320 | Plugins::class, |
| 321 | 321 | Plugins::EVENT_AFTER_INSTALL_PLUGIN, |
| 322 | - function (PluginEvent $event) { |
|
| 322 | + function(PluginEvent $event) { |
|
| 323 | 323 | if ($event->plugin === $this) { |
| 324 | 324 | // Invalidate our caches after we've been installed |
| 325 | 325 | $this->clearAllCaches(); |
@@ -346,7 +346,7 @@ discard block |
||
| 346 | 346 | Event::on( |
| 347 | 347 | CraftVariable::class, |
| 348 | 348 | CraftVariable::EVENT_INIT, |
| 349 | - function (Event $event) { |
|
| 349 | + function(Event $event) { |
|
| 350 | 350 | /** @var CraftVariable $variable */ |
| 351 | 351 | $variable = $event->sender; |
| 352 | 352 | $variable->set('retour', [ |
@@ -359,7 +359,7 @@ discard block |
||
| 359 | 359 | Event::on( |
| 360 | 360 | Elements::class, |
| 361 | 361 | Elements::EVENT_BEFORE_SAVE_ELEMENT, |
| 362 | - function (ElementEvent $event) { |
|
| 362 | + function(ElementEvent $event) { |
|
| 363 | 363 | Craft::debug( |
| 364 | 364 | 'Elements::EVENT_BEFORE_SAVE_ELEMENT', |
| 365 | 365 | __METHOD__ |
@@ -390,7 +390,7 @@ discard block |
||
| 390 | 390 | Event::on( |
| 391 | 391 | Elements::class, |
| 392 | 392 | Elements::EVENT_AFTER_SAVE_ELEMENT, |
| 393 | - function (ElementEvent $event) { |
|
| 393 | + function(ElementEvent $event) { |
|
| 394 | 394 | Craft::debug( |
| 395 | 395 | 'Elements::EVENT_AFTER_SAVE_ELEMENT', |
| 396 | 396 | __METHOD__ |
@@ -412,7 +412,7 @@ discard block |
||
| 412 | 412 | Event::on( |
| 413 | 413 | Plugins::class, |
| 414 | 414 | Plugins::EVENT_AFTER_LOAD_PLUGINS, |
| 415 | - function () { |
|
| 415 | + function() { |
|
| 416 | 416 | // Install these only after all other plugins have loaded |
| 417 | 417 | $request = Craft::$app->getRequest(); |
| 418 | 418 | // Only respond to non-console site requests |
@@ -430,26 +430,26 @@ discard block |
||
| 430 | 430 | Event::on( |
| 431 | 431 | Gql::class, |
| 432 | 432 | Gql::EVENT_REGISTER_GQL_TYPES, |
| 433 | - function (RegisterGqlTypesEvent $event) { |
|
| 433 | + function(RegisterGqlTypesEvent $event) { |
|
| 434 | 434 | Craft::debug( |
| 435 | 435 | 'Gql::EVENT_REGISTER_GQL_TYPES', |
| 436 | 436 | __METHOD__ |
| 437 | 437 | ); |
| 438 | - $event->types[] = RetourInterface::class; |
|
| 438 | + $event->types[ ] = RetourInterface::class; |
|
| 439 | 439 | } |
| 440 | 440 | ); |
| 441 | 441 | // Handler: Gql::EVENT_REGISTER_GQL_QUERIES |
| 442 | 442 | Event::on( |
| 443 | 443 | Gql::class, |
| 444 | 444 | Gql::EVENT_REGISTER_GQL_QUERIES, |
| 445 | - function (RegisterGqlQueriesEvent $event) { |
|
| 445 | + function(RegisterGqlQueriesEvent $event) { |
|
| 446 | 446 | Craft::debug( |
| 447 | 447 | 'Gql::EVENT_REGISTER_GQL_QUERIES', |
| 448 | 448 | __METHOD__ |
| 449 | 449 | ); |
| 450 | 450 | $queries = RetourQuery::getQueries(); |
| 451 | 451 | foreach ($queries as $key => $value) { |
| 452 | - $event->queries[$key] = $value; |
|
| 452 | + $event->queries[ $key ] = $value; |
|
| 453 | 453 | } |
| 454 | 454 | } |
| 455 | 455 | ); |
@@ -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 | } |
@@ -474,7 +474,7 @@ discard block |
||
| 474 | 474 | Event::on( |
| 475 | 475 | Schema::class, |
| 476 | 476 | AlterSchemaFields::EVENT, |
| 477 | - [GetCraftQLSchema::class, 'handle'] |
|
| 477 | + [ GetCraftQLSchema::class, 'handle' ] |
|
| 478 | 478 | ); |
| 479 | 479 | } |
| 480 | 480 | } |
@@ -488,7 +488,7 @@ discard block |
||
| 488 | 488 | Event::on( |
| 489 | 489 | UrlManager::class, |
| 490 | 490 | UrlManager::EVENT_REGISTER_SITE_URL_RULES, |
| 491 | - function (RegisterUrlRulesEvent $event) { |
|
| 491 | + function(RegisterUrlRulesEvent $event) { |
|
| 492 | 492 | Craft::debug( |
| 493 | 493 | 'UrlManager::EVENT_REGISTER_SITE_URL_RULES', |
| 494 | 494 | __METHOD__ |
@@ -511,15 +511,15 @@ discard block |
||
| 511 | 511 | Event::on( |
| 512 | 512 | Dashboard::class, |
| 513 | 513 | Dashboard::EVENT_REGISTER_WIDGET_TYPES, |
| 514 | - function (RegisterComponentTypesEvent $event) { |
|
| 515 | - $event->types[] = RetourWidget::class; |
|
| 514 | + function(RegisterComponentTypesEvent $event) { |
|
| 515 | + $event->types[ ] = RetourWidget::class; |
|
| 516 | 516 | } |
| 517 | 517 | ); |
| 518 | 518 | // Handler: UrlManager::EVENT_REGISTER_CP_URL_RULES |
| 519 | 519 | Event::on( |
| 520 | 520 | UrlManager::class, |
| 521 | 521 | UrlManager::EVENT_REGISTER_CP_URL_RULES, |
| 522 | - function (RegisterUrlRulesEvent $event) { |
|
| 522 | + function(RegisterUrlRulesEvent $event) { |
|
| 523 | 523 | Craft::debug( |
| 524 | 524 | 'UrlManager::EVENT_REGISTER_CP_URL_RULES', |
| 525 | 525 | __METHOD__ |
@@ -535,13 +535,13 @@ discard block |
||
| 535 | 535 | Event::on( |
| 536 | 536 | UserPermissions::class, |
| 537 | 537 | UserPermissions::EVENT_REGISTER_PERMISSIONS, |
| 538 | - function (RegisterUserPermissionsEvent $event) { |
|
| 538 | + function(RegisterUserPermissionsEvent $event) { |
|
| 539 | 539 | Craft::debug( |
| 540 | 540 | 'UserPermissions::EVENT_REGISTER_PERMISSIONS', |
| 541 | 541 | __METHOD__ |
| 542 | 542 | ); |
| 543 | 543 | // Register our custom permissions |
| 544 | - $event->permissions[Craft::t('retour', 'Retour')] = $this->customAdminCpPermissions(); |
|
| 544 | + $event->permissions[ Craft::t('retour', 'Retour') ] = $this->customAdminCpPermissions(); |
|
| 545 | 545 | } |
| 546 | 546 | ); |
| 547 | 547 | } |
@@ -557,7 +557,7 @@ discard block |
||
| 557 | 557 | Event::on( |
| 558 | 558 | ErrorHandler::class, |
| 559 | 559 | ErrorHandler::EVENT_BEFORE_HANDLE_EXCEPTION, |
| 560 | - function (ExceptionEvent $event) { |
|
| 560 | + function(ExceptionEvent $event) { |
|
| 561 | 561 | Craft::debug( |
| 562 | 562 | 'ErrorHandler::EVENT_BEFORE_HANDLE_EXCEPTION', |
| 563 | 563 | __METHOD__ |
@@ -641,7 +641,7 @@ discard block |
||
| 641 | 641 | [ |
| 642 | 642 | 'key' => 'retour-redirect-caches', |
| 643 | 643 | 'label' => Craft::t('retour', 'Retour redirect caches'), |
| 644 | - 'action' => [self::$plugin->redirects, 'invalidateCaches'], |
|
| 644 | + 'action' => [ self::$plugin->redirects, 'invalidateCaches' ], |
|
| 645 | 645 | ], |
| 646 | 646 | ]; |
| 647 | 647 | } |