@@ -99,7 +99,7 @@ discard block |
||
| 99 | 99 | /** |
| 100 | 100 | * @var array The URIs for the element before it was saved |
| 101 | 101 | */ |
| 102 | - public $oldElementUris = []; |
|
| 102 | + public $oldElementUris = [ ]; |
|
| 103 | 103 | |
| 104 | 104 | // Public Methods |
| 105 | 105 | // ========================================================================= |
@@ -130,7 +130,7 @@ discard block |
||
| 130 | 130 | Craft::t( |
| 131 | 131 | 'retour', |
| 132 | 132 | '{name} plugin loaded', |
| 133 | - ['name' => $this->name] |
|
| 133 | + [ 'name' => $this->name ] |
|
| 134 | 134 | ), |
| 135 | 135 | __METHOD__ |
| 136 | 136 | ); |
@@ -150,18 +150,18 @@ discard block |
||
| 150 | 150 | */ |
| 151 | 151 | public function getCpNavItem() |
| 152 | 152 | { |
| 153 | - $subNavs = []; |
|
| 153 | + $subNavs = [ ]; |
|
| 154 | 154 | $navItem = parent::getCpNavItem(); |
| 155 | 155 | $currentUser = Craft::$app->getUser()->getIdentity(); |
| 156 | 156 | // Only show sub-navs the user has permission to view |
| 157 | 157 | if ($currentUser->can('retour:dashboard')) { |
| 158 | - $subNavs['dashboard'] = [ |
|
| 158 | + $subNavs[ 'dashboard' ] = [ |
|
| 159 | 159 | 'label' => 'Dashboard', |
| 160 | 160 | 'url' => 'retour/dashboard', |
| 161 | 161 | ]; |
| 162 | 162 | } |
| 163 | 163 | if ($currentUser->can('retour:redirects')) { |
| 164 | - $subNavs['redirects'] = [ |
|
| 164 | + $subNavs[ 'redirects' ] = [ |
|
| 165 | 165 | 'label' => 'Redirects', |
| 166 | 166 | 'url' => 'retour/redirects', |
| 167 | 167 | ]; |
@@ -172,7 +172,7 @@ discard block |
||
| 172 | 172 | $editableSettings = false; |
| 173 | 173 | } |
| 174 | 174 | if ($currentUser->can('retour:settings') && $editableSettings) { |
| 175 | - $subNavs['settings'] = [ |
|
| 175 | + $subNavs[ 'settings' ] = [ |
|
| 176 | 176 | 'label' => 'Settings', |
| 177 | 177 | 'url' => 'retour/settings', |
| 178 | 178 | ]; |
@@ -231,7 +231,7 @@ discard block |
||
| 231 | 231 | Event::on( |
| 232 | 232 | ClearCaches::class, |
| 233 | 233 | ClearCaches::EVENT_REGISTER_CACHE_OPTIONS, |
| 234 | - function (RegisterCacheOptionsEvent $event) { |
|
| 234 | + function(RegisterCacheOptionsEvent $event) { |
|
| 235 | 235 | Craft::debug( |
| 236 | 236 | 'ClearCaches::EVENT_REGISTER_CACHE_OPTIONS', |
| 237 | 237 | __METHOD__ |
@@ -247,7 +247,7 @@ discard block |
||
| 247 | 247 | Event::on( |
| 248 | 248 | Plugins::class, |
| 249 | 249 | Plugins::EVENT_AFTER_INSTALL_PLUGIN, |
| 250 | - function (PluginEvent $event) { |
|
| 250 | + function(PluginEvent $event) { |
|
| 251 | 251 | if ($event->plugin === $this) { |
| 252 | 252 | // Invalidate our caches after we've been installed |
| 253 | 253 | $this->clearAllCaches(); |
@@ -274,7 +274,7 @@ discard block |
||
| 274 | 274 | Event::on( |
| 275 | 275 | CraftVariable::class, |
| 276 | 276 | CraftVariable::EVENT_INIT, |
| 277 | - function (Event $event) { |
|
| 277 | + function(Event $event) { |
|
| 278 | 278 | /** @var CraftVariable $variable */ |
| 279 | 279 | $variable = $event->sender; |
| 280 | 280 | $variable->set('retour', RetourVariable::class); |
@@ -284,7 +284,7 @@ discard block |
||
| 284 | 284 | Event::on( |
| 285 | 285 | Elements::class, |
| 286 | 286 | Elements::EVENT_BEFORE_SAVE_ELEMENT, |
| 287 | - function (ElementEvent $event) { |
|
| 287 | + function(ElementEvent $event) { |
|
| 288 | 288 | Craft::debug( |
| 289 | 289 | 'Elements::EVENT_BEFORE_SAVE_ELEMENT', |
| 290 | 290 | __METHOD__ |
@@ -299,8 +299,8 @@ discard block |
||
| 299 | 299 | if ($oldElement !== null) { |
| 300 | 300 | // Stash the old URLs by element id, and do so only once, |
| 301 | 301 | // in case we are called more than once per request |
| 302 | - if (empty($this->oldElementUris[$oldElement->id])) { |
|
| 303 | - $this->oldElementUris[$oldElement->id] = $this->getAllElementUris($oldElement); |
|
| 302 | + if (empty($this->oldElementUris[ $oldElement->id ])) { |
|
| 303 | + $this->oldElementUris[ $oldElement->id ] = $this->getAllElementUris($oldElement); |
|
| 304 | 304 | } |
| 305 | 305 | } |
| 306 | 306 | } |
@@ -311,7 +311,7 @@ discard block |
||
| 311 | 311 | Event::on( |
| 312 | 312 | Elements::class, |
| 313 | 313 | Elements::EVENT_AFTER_SAVE_ELEMENT, |
| 314 | - function (ElementEvent $event) { |
|
| 314 | + function(ElementEvent $event) { |
|
| 315 | 315 | Craft::debug( |
| 316 | 316 | 'Elements::EVENT_AFTER_SAVE_ELEMENT', |
| 317 | 317 | __METHOD__ |
@@ -327,7 +327,7 @@ discard block |
||
| 327 | 327 | Event::on( |
| 328 | 328 | Plugins::class, |
| 329 | 329 | Plugins::EVENT_AFTER_LOAD_PLUGINS, |
| 330 | - function () { |
|
| 330 | + function() { |
|
| 331 | 331 | // Install these only after all other plugins have loaded |
| 332 | 332 | $request = Craft::$app->getRequest(); |
| 333 | 333 | // Only respond to non-console site requests |
@@ -351,7 +351,7 @@ discard block |
||
| 351 | 351 | Event::on( |
| 352 | 352 | UrlManager::class, |
| 353 | 353 | UrlManager::EVENT_REGISTER_SITE_URL_RULES, |
| 354 | - function (RegisterUrlRulesEvent $event) { |
|
| 354 | + function(RegisterUrlRulesEvent $event) { |
|
| 355 | 355 | Craft::debug( |
| 356 | 356 | 'UrlManager::EVENT_REGISTER_SITE_URL_RULES', |
| 357 | 357 | __METHOD__ |
@@ -374,15 +374,15 @@ discard block |
||
| 374 | 374 | Event::on( |
| 375 | 375 | Dashboard::class, |
| 376 | 376 | Dashboard::EVENT_REGISTER_WIDGET_TYPES, |
| 377 | - function (RegisterComponentTypesEvent $event) { |
|
| 378 | - $event->types[] = RetourWidget::class; |
|
| 377 | + function(RegisterComponentTypesEvent $event) { |
|
| 378 | + $event->types[ ] = RetourWidget::class; |
|
| 379 | 379 | } |
| 380 | 380 | ); |
| 381 | 381 | // Handler: UrlManager::EVENT_REGISTER_CP_URL_RULES |
| 382 | 382 | Event::on( |
| 383 | 383 | UrlManager::class, |
| 384 | 384 | UrlManager::EVENT_REGISTER_CP_URL_RULES, |
| 385 | - function (RegisterUrlRulesEvent $event) { |
|
| 385 | + function(RegisterUrlRulesEvent $event) { |
|
| 386 | 386 | Craft::debug( |
| 387 | 387 | 'UrlManager::EVENT_REGISTER_CP_URL_RULES', |
| 388 | 388 | __METHOD__ |
@@ -398,13 +398,13 @@ discard block |
||
| 398 | 398 | Event::on( |
| 399 | 399 | UserPermissions::class, |
| 400 | 400 | UserPermissions::EVENT_REGISTER_PERMISSIONS, |
| 401 | - function (RegisterUserPermissionsEvent $event) { |
|
| 401 | + function(RegisterUserPermissionsEvent $event) { |
|
| 402 | 402 | Craft::debug( |
| 403 | 403 | 'UserPermissions::EVENT_REGISTER_PERMISSIONS', |
| 404 | 404 | __METHOD__ |
| 405 | 405 | ); |
| 406 | 406 | // Register our custom permissions |
| 407 | - $event->permissions[Craft::t('retour', 'Retour')] = $this->customAdminCpPermissions(); |
|
| 407 | + $event->permissions[ Craft::t('retour', 'Retour') ] = $this->customAdminCpPermissions(); |
|
| 408 | 408 | } |
| 409 | 409 | ); |
| 410 | 410 | } |
@@ -420,7 +420,7 @@ discard block |
||
| 420 | 420 | Event::on( |
| 421 | 421 | ErrorHandler::class, |
| 422 | 422 | ErrorHandler::EVENT_BEFORE_HANDLE_EXCEPTION, |
| 423 | - function (ExceptionEvent $event) { |
|
| 423 | + function(ExceptionEvent $event) { |
|
| 424 | 424 | Craft::debug( |
| 425 | 425 | 'ErrorHandler::EVENT_BEFORE_HANDLE_EXCEPTION', |
| 426 | 426 | __METHOD__ |
@@ -463,16 +463,16 @@ discard block |
||
| 463 | 463 | protected function handleElementUriChange(Element $element) |
| 464 | 464 | { |
| 465 | 465 | $uris = $this->getAllElementUris($element); |
| 466 | - if (!empty($this->oldElementUris[$element->id])) { |
|
| 467 | - $oldElementUris = $this->oldElementUris[$element->id]; |
|
| 466 | + if (!empty($this->oldElementUris[ $element->id ])) { |
|
| 467 | + $oldElementUris = $this->oldElementUris[ $element->id ]; |
|
| 468 | 468 | foreach ($uris as $siteId => $newUri) { |
| 469 | - if (!empty($oldElementUris[$siteId])) { |
|
| 470 | - $oldUri = $oldElementUris[$siteId]; |
|
| 469 | + if (!empty($oldElementUris[ $siteId ])) { |
|
| 470 | + $oldUri = $oldElementUris[ $siteId ]; |
|
| 471 | 471 | Craft::debug( |
| 472 | 472 | Craft::t( |
| 473 | 473 | 'retour', |
| 474 | 474 | 'Comparing old: {oldUri} to new: {newUri}', |
| 475 | - ['oldUri' => print_r($oldUri, true), 'newUri' => print_r($newUri, true)] |
|
| 475 | + [ 'oldUri' => print_r($oldUri, true), 'newUri' => print_r($newUri, true) ] |
|
| 476 | 476 | ), |
| 477 | 477 | __METHOD__ |
| 478 | 478 | ); |
@@ -507,12 +507,12 @@ discard block |
||
| 507 | 507 | */ |
| 508 | 508 | protected function getAllElementUris(Element $element): array |
| 509 | 509 | { |
| 510 | - $uris = []; |
|
| 510 | + $uris = [ ]; |
|
| 511 | 511 | $sites = Craft::$app->getSites()->getAllSites(); |
| 512 | 512 | foreach ($sites as $site) { |
| 513 | 513 | $uri = Craft::$app->getElements()->getElementUriForSite($element->id, $site->id); |
| 514 | 514 | if ($uri !== null) { |
| 515 | - $uris[$site->id] = $uri; |
|
| 515 | + $uris[ $site->id ] = $uri; |
|
| 516 | 516 | } |
| 517 | 517 | } |
| 518 | 518 | |
@@ -520,7 +520,7 @@ discard block |
||
| 520 | 520 | Craft::t( |
| 521 | 521 | 'retour', |
| 522 | 522 | 'Getting Element URIs: {uris}', |
| 523 | - ['uris' => print_r($uris, true)] |
|
| 523 | + [ 'uris' => print_r($uris, true) ] |
|
| 524 | 524 | ), |
| 525 | 525 | __METHOD__ |
| 526 | 526 | ); |
@@ -584,7 +584,7 @@ discard block |
||
| 584 | 584 | [ |
| 585 | 585 | 'key' => 'retour-redirect-caches', |
| 586 | 586 | 'label' => Craft::t('retour', 'Retour redirect caches'), |
| 587 | - 'action' => [self::$plugin->redirects, 'invalidateCaches'], |
|
| 587 | + 'action' => [ self::$plugin->redirects, 'invalidateCaches' ], |
|
| 588 | 588 | ], |
| 589 | 589 | ]; |
| 590 | 590 | } |