@@ -110,7 +110,7 @@ discard block |
||
| 110 | 110 | /** |
| 111 | 111 | * @var array The URIs for the element before it was saved |
| 112 | 112 | */ |
| 113 | - public $oldElementUris = []; |
|
| 113 | + public $oldElementUris = [ ]; |
|
| 114 | 114 | |
| 115 | 115 | // Public Methods |
| 116 | 116 | // ========================================================================= |
@@ -142,7 +142,7 @@ discard block |
||
| 142 | 142 | Craft::t( |
| 143 | 143 | 'retour', |
| 144 | 144 | '{name} plugin loaded', |
| 145 | - ['name' => $this->name] |
|
| 145 | + [ 'name' => $this->name ] |
|
| 146 | 146 | ), |
| 147 | 147 | __METHOD__ |
| 148 | 148 | ); |
@@ -162,18 +162,18 @@ discard block |
||
| 162 | 162 | */ |
| 163 | 163 | public function getCpNavItem() |
| 164 | 164 | { |
| 165 | - $subNavs = []; |
|
| 165 | + $subNavs = [ ]; |
|
| 166 | 166 | $navItem = parent::getCpNavItem(); |
| 167 | 167 | $currentUser = Craft::$app->getUser()->getIdentity(); |
| 168 | 168 | // Only show sub-navs the user has permission to view |
| 169 | 169 | if ($currentUser->can('retour:dashboard')) { |
| 170 | - $subNavs['dashboard'] = [ |
|
| 170 | + $subNavs[ 'dashboard' ] = [ |
|
| 171 | 171 | 'label' => 'Dashboard', |
| 172 | 172 | 'url' => 'retour/dashboard', |
| 173 | 173 | ]; |
| 174 | 174 | } |
| 175 | 175 | if ($currentUser->can('retour:redirects')) { |
| 176 | - $subNavs['redirects'] = [ |
|
| 176 | + $subNavs[ 'redirects' ] = [ |
|
| 177 | 177 | 'label' => 'Redirects', |
| 178 | 178 | 'url' => 'retour/redirects', |
| 179 | 179 | ]; |
@@ -184,7 +184,7 @@ discard block |
||
| 184 | 184 | $editableSettings = false; |
| 185 | 185 | } |
| 186 | 186 | if ($currentUser->can('retour:settings') && $editableSettings) { |
| 187 | - $subNavs['settings'] = [ |
|
| 187 | + $subNavs[ 'settings' ] = [ |
|
| 188 | 188 | 'label' => 'Settings', |
| 189 | 189 | 'url' => 'retour/settings', |
| 190 | 190 | ]; |
@@ -243,7 +243,7 @@ discard block |
||
| 243 | 243 | Event::on( |
| 244 | 244 | ClearCaches::class, |
| 245 | 245 | ClearCaches::EVENT_REGISTER_CACHE_OPTIONS, |
| 246 | - function (RegisterCacheOptionsEvent $event) { |
|
| 246 | + function(RegisterCacheOptionsEvent $event) { |
|
| 247 | 247 | Craft::debug( |
| 248 | 248 | 'ClearCaches::EVENT_REGISTER_CACHE_OPTIONS', |
| 249 | 249 | __METHOD__ |
@@ -259,7 +259,7 @@ discard block |
||
| 259 | 259 | Event::on( |
| 260 | 260 | Plugins::class, |
| 261 | 261 | Plugins::EVENT_AFTER_INSTALL_PLUGIN, |
| 262 | - function (PluginEvent $event) { |
|
| 262 | + function(PluginEvent $event) { |
|
| 263 | 263 | if ($event->plugin === $this) { |
| 264 | 264 | // Invalidate our caches after we've been installed |
| 265 | 265 | $this->clearAllCaches(); |
@@ -286,7 +286,7 @@ discard block |
||
| 286 | 286 | Event::on( |
| 287 | 287 | CraftVariable::class, |
| 288 | 288 | CraftVariable::EVENT_INIT, |
| 289 | - function (Event $event) { |
|
| 289 | + function(Event $event) { |
|
| 290 | 290 | /** @var CraftVariable $variable */ |
| 291 | 291 | $variable = $event->sender; |
| 292 | 292 | $variable->set('retour', RetourVariable::class); |
@@ -296,7 +296,7 @@ discard block |
||
| 296 | 296 | Event::on( |
| 297 | 297 | Elements::class, |
| 298 | 298 | Elements::EVENT_BEFORE_SAVE_ELEMENT, |
| 299 | - function (ElementEvent $event) { |
|
| 299 | + function(ElementEvent $event) { |
|
| 300 | 300 | Craft::debug( |
| 301 | 301 | 'Elements::EVENT_BEFORE_SAVE_ELEMENT', |
| 302 | 302 | __METHOD__ |
@@ -321,8 +321,8 @@ discard block |
||
| 321 | 321 | if (strpos($element->uri, '__temp_') === false && !$element->propagating) { |
| 322 | 322 | // Stash the old URLs by element id, and do so only once, |
| 323 | 323 | // in case we are called more than once per request |
| 324 | - if (empty($this->oldElementUris[$element->id])) { |
|
| 325 | - $this->oldElementUris[$element->id] = $this->getAllElementUris($element); |
|
| 324 | + if (empty($this->oldElementUris[ $element->id ])) { |
|
| 325 | + $this->oldElementUris[ $element->id ] = $this->getAllElementUris($element); |
|
| 326 | 326 | } |
| 327 | 327 | } |
| 328 | 328 | } |
@@ -333,7 +333,7 @@ discard block |
||
| 333 | 333 | Event::on( |
| 334 | 334 | Elements::class, |
| 335 | 335 | Elements::EVENT_AFTER_SAVE_ELEMENT, |
| 336 | - function (ElementEvent $event) { |
|
| 336 | + function(ElementEvent $event) { |
|
| 337 | 337 | Craft::debug( |
| 338 | 338 | 'Elements::EVENT_AFTER_SAVE_ELEMENT', |
| 339 | 339 | __METHOD__ |
@@ -355,7 +355,7 @@ discard block |
||
| 355 | 355 | Event::on( |
| 356 | 356 | Plugins::class, |
| 357 | 357 | Plugins::EVENT_AFTER_LOAD_PLUGINS, |
| 358 | - function () { |
|
| 358 | + function() { |
|
| 359 | 359 | // Install these only after all other plugins have loaded |
| 360 | 360 | $request = Craft::$app->getRequest(); |
| 361 | 361 | // Only respond to non-console site requests |
@@ -373,7 +373,7 @@ discard block |
||
| 373 | 373 | Event::on( |
| 374 | 374 | Schema::class, |
| 375 | 375 | AlterSchemaFields::EVENT, |
| 376 | - [GetCraftQLSchema::class, 'handle'] |
|
| 376 | + [ GetCraftQLSchema::class, 'handle' ] |
|
| 377 | 377 | ); |
| 378 | 378 | } |
| 379 | 379 | } |
@@ -387,7 +387,7 @@ discard block |
||
| 387 | 387 | Event::on( |
| 388 | 388 | UrlManager::class, |
| 389 | 389 | UrlManager::EVENT_REGISTER_SITE_URL_RULES, |
| 390 | - function (RegisterUrlRulesEvent $event) { |
|
| 390 | + function(RegisterUrlRulesEvent $event) { |
|
| 391 | 391 | Craft::debug( |
| 392 | 392 | 'UrlManager::EVENT_REGISTER_SITE_URL_RULES', |
| 393 | 393 | __METHOD__ |
@@ -410,15 +410,15 @@ discard block |
||
| 410 | 410 | Event::on( |
| 411 | 411 | Dashboard::class, |
| 412 | 412 | Dashboard::EVENT_REGISTER_WIDGET_TYPES, |
| 413 | - function (RegisterComponentTypesEvent $event) { |
|
| 414 | - $event->types[] = RetourWidget::class; |
|
| 413 | + function(RegisterComponentTypesEvent $event) { |
|
| 414 | + $event->types[ ] = RetourWidget::class; |
|
| 415 | 415 | } |
| 416 | 416 | ); |
| 417 | 417 | // Handler: UrlManager::EVENT_REGISTER_CP_URL_RULES |
| 418 | 418 | Event::on( |
| 419 | 419 | UrlManager::class, |
| 420 | 420 | UrlManager::EVENT_REGISTER_CP_URL_RULES, |
| 421 | - function (RegisterUrlRulesEvent $event) { |
|
| 421 | + function(RegisterUrlRulesEvent $event) { |
|
| 422 | 422 | Craft::debug( |
| 423 | 423 | 'UrlManager::EVENT_REGISTER_CP_URL_RULES', |
| 424 | 424 | __METHOD__ |
@@ -434,13 +434,13 @@ discard block |
||
| 434 | 434 | Event::on( |
| 435 | 435 | UserPermissions::class, |
| 436 | 436 | UserPermissions::EVENT_REGISTER_PERMISSIONS, |
| 437 | - function (RegisterUserPermissionsEvent $event) { |
|
| 437 | + function(RegisterUserPermissionsEvent $event) { |
|
| 438 | 438 | Craft::debug( |
| 439 | 439 | 'UserPermissions::EVENT_REGISTER_PERMISSIONS', |
| 440 | 440 | __METHOD__ |
| 441 | 441 | ); |
| 442 | 442 | // Register our custom permissions |
| 443 | - $event->permissions[Craft::t('retour', 'Retour')] = $this->customAdminCpPermissions(); |
|
| 443 | + $event->permissions[ Craft::t('retour', 'Retour') ] = $this->customAdminCpPermissions(); |
|
| 444 | 444 | } |
| 445 | 445 | ); |
| 446 | 446 | } |
@@ -456,7 +456,7 @@ discard block |
||
| 456 | 456 | Event::on( |
| 457 | 457 | ErrorHandler::class, |
| 458 | 458 | ErrorHandler::EVENT_BEFORE_HANDLE_EXCEPTION, |
| 459 | - function (ExceptionEvent $event) { |
|
| 459 | + function(ExceptionEvent $event) { |
|
| 460 | 460 | Craft::debug( |
| 461 | 461 | 'ErrorHandler::EVENT_BEFORE_HANDLE_EXCEPTION', |
| 462 | 462 | __METHOD__ |
@@ -499,16 +499,16 @@ discard block |
||
| 499 | 499 | protected function handleElementUriChange(Element $element) |
| 500 | 500 | { |
| 501 | 501 | $uris = $this->getAllElementUris($element); |
| 502 | - if (!empty($this->oldElementUris[$element->id])) { |
|
| 503 | - $oldElementUris = $this->oldElementUris[$element->id]; |
|
| 502 | + if (!empty($this->oldElementUris[ $element->id ])) { |
|
| 503 | + $oldElementUris = $this->oldElementUris[ $element->id ]; |
|
| 504 | 504 | foreach ($uris as $siteId => $newUri) { |
| 505 | - if (!empty($oldElementUris[$siteId])) { |
|
| 506 | - $oldUri = $oldElementUris[$siteId]; |
|
| 505 | + if (!empty($oldElementUris[ $siteId ])) { |
|
| 506 | + $oldUri = $oldElementUris[ $siteId ]; |
|
| 507 | 507 | Craft::debug( |
| 508 | 508 | Craft::t( |
| 509 | 509 | 'retour', |
| 510 | 510 | 'Comparing old: {oldUri} to new: {newUri}', |
| 511 | - ['oldUri' => print_r($oldUri, true), 'newUri' => print_r($newUri, true)] |
|
| 511 | + [ 'oldUri' => print_r($oldUri, true), 'newUri' => print_r($newUri, true) ] |
|
| 512 | 512 | ), |
| 513 | 513 | __METHOD__ |
| 514 | 514 | ); |
@@ -548,13 +548,13 @@ discard block |
||
| 548 | 548 | */ |
| 549 | 549 | protected function getAllElementUris(Element $element): array |
| 550 | 550 | { |
| 551 | - $uris = []; |
|
| 551 | + $uris = [ ]; |
|
| 552 | 552 | if (!self::$craft32 || !ElementHelper::isDraftOrRevision($element)) { |
| 553 | 553 | $sites = Craft::$app->getSites()->getAllSites(); |
| 554 | 554 | foreach ($sites as $site) { |
| 555 | 555 | $uri = Craft::$app->getElements()->getElementUriForSite($element->id, $site->id); |
| 556 | 556 | if ($uri !== null) { |
| 557 | - $uris[$site->id] = $uri; |
|
| 557 | + $uris[ $site->id ] = $uri; |
|
| 558 | 558 | } |
| 559 | 559 | } |
| 560 | 560 | } |
@@ -563,7 +563,7 @@ discard block |
||
| 563 | 563 | Craft::t( |
| 564 | 564 | 'retour', |
| 565 | 565 | 'Getting Element URIs: {uris}', |
| 566 | - ['uris' => print_r($uris, true)] |
|
| 566 | + [ 'uris' => print_r($uris, true) ] |
|
| 567 | 567 | ), |
| 568 | 568 | __METHOD__ |
| 569 | 569 | ); |
@@ -627,7 +627,7 @@ discard block |
||
| 627 | 627 | [ |
| 628 | 628 | 'key' => 'retour-redirect-caches', |
| 629 | 629 | 'label' => Craft::t('retour', 'Retour redirect caches'), |
| 630 | - 'action' => [self::$plugin->redirects, 'invalidateCaches'], |
|
| 630 | + 'action' => [ self::$plugin->redirects, 'invalidateCaches' ], |
|
| 631 | 631 | ], |
| 632 | 632 | ]; |
| 633 | 633 | } |