@@ -89,7 +89,7 @@ discard block |
||
| 89 | 89 | /** |
| 90 | 90 | * @var array The URIs for the element before it was saved |
| 91 | 91 | */ |
| 92 | - public $oldElementUris = []; |
|
| 92 | + public $oldElementUris = [ ]; |
|
| 93 | 93 | |
| 94 | 94 | // Public Methods |
| 95 | 95 | // ========================================================================= |
@@ -114,7 +114,7 @@ discard block |
||
| 114 | 114 | Craft::t( |
| 115 | 115 | 'retour', |
| 116 | 116 | '{name} plugin loaded', |
| 117 | - ['name' => $this->name] |
|
| 117 | + [ 'name' => $this->name ] |
|
| 118 | 118 | ), |
| 119 | 119 | __METHOD__ |
| 120 | 120 | ); |
@@ -134,24 +134,24 @@ discard block |
||
| 134 | 134 | */ |
| 135 | 135 | public function getCpNavItem() |
| 136 | 136 | { |
| 137 | - $subNavs = []; |
|
| 137 | + $subNavs = [ ]; |
|
| 138 | 138 | $navItem = parent::getCpNavItem(); |
| 139 | 139 | $currentUser = Craft::$app->getUser()->getIdentity(); |
| 140 | 140 | // Only show sub-navs the user has permission to view |
| 141 | 141 | if ($currentUser->can('retour:dashboard')) { |
| 142 | - $subNavs['dashboard'] = [ |
|
| 142 | + $subNavs[ 'dashboard' ] = [ |
|
| 143 | 143 | 'label' => 'Dashboard', |
| 144 | 144 | 'url' => 'retour/dashboard', |
| 145 | 145 | ]; |
| 146 | 146 | } |
| 147 | 147 | if ($currentUser->can('retour:redirects')) { |
| 148 | - $subNavs['redirects'] = [ |
|
| 148 | + $subNavs[ 'redirects' ] = [ |
|
| 149 | 149 | 'label' => 'Redirects', |
| 150 | 150 | 'url' => 'retour/redirects', |
| 151 | 151 | ]; |
| 152 | 152 | } |
| 153 | 153 | if ($currentUser->can('retour:settings')) { |
| 154 | - $subNavs['settings'] = [ |
|
| 154 | + $subNavs[ 'settings' ] = [ |
|
| 155 | 155 | 'label' => 'Settings', |
| 156 | 156 | 'url' => 'retour/settings', |
| 157 | 157 | ]; |
@@ -210,7 +210,7 @@ discard block |
||
| 210 | 210 | Event::on( |
| 211 | 211 | Plugins::class, |
| 212 | 212 | Plugins::EVENT_AFTER_INSTALL_PLUGIN, |
| 213 | - function (PluginEvent $event) { |
|
| 213 | + function(PluginEvent $event) { |
|
| 214 | 214 | if ($event->plugin === $this) { |
| 215 | 215 | // Invalidate our caches after we've been installed |
| 216 | 216 | $this->clearAllCaches(); |
@@ -237,7 +237,7 @@ discard block |
||
| 237 | 237 | Event::on( |
| 238 | 238 | CraftVariable::class, |
| 239 | 239 | CraftVariable::EVENT_INIT, |
| 240 | - function (Event $event) { |
|
| 240 | + function(Event $event) { |
|
| 241 | 241 | /** @var CraftVariable $variable */ |
| 242 | 242 | $variable = $event->sender; |
| 243 | 243 | $variable->set('retour', RetourVariable::class); |
@@ -247,7 +247,7 @@ discard block |
||
| 247 | 247 | Event::on( |
| 248 | 248 | Elements::class, |
| 249 | 249 | Elements::EVENT_BEFORE_SAVE_ELEMENT, |
| 250 | - function (ElementEvent $event) { |
|
| 250 | + function(ElementEvent $event) { |
|
| 251 | 251 | Craft::debug( |
| 252 | 252 | 'Elements::EVENT_BEFORE_SAVE_ELEMENT', |
| 253 | 253 | __METHOD__ |
@@ -262,8 +262,8 @@ discard block |
||
| 262 | 262 | if ($oldElement !== null) { |
| 263 | 263 | // Stash the old URLs by element id, and do so only once, |
| 264 | 264 | // in case we are called more than once per request |
| 265 | - if (empty($this->oldElementUris[$oldElement->id])) { |
|
| 266 | - $this->oldElementUris[$oldElement->id] = $this->getAllElementUris($oldElement); |
|
| 265 | + if (empty($this->oldElementUris[ $oldElement->id ])) { |
|
| 266 | + $this->oldElementUris[ $oldElement->id ] = $this->getAllElementUris($oldElement); |
|
| 267 | 267 | } |
| 268 | 268 | } |
| 269 | 269 | } |
@@ -274,7 +274,7 @@ discard block |
||
| 274 | 274 | Event::on( |
| 275 | 275 | Elements::class, |
| 276 | 276 | Elements::EVENT_AFTER_SAVE_ELEMENT, |
| 277 | - function (ElementEvent $event) { |
|
| 277 | + function(ElementEvent $event) { |
|
| 278 | 278 | Craft::debug( |
| 279 | 279 | 'Elements::EVENT_AFTER_SAVE_ELEMENT', |
| 280 | 280 | __METHOD__ |
@@ -290,7 +290,7 @@ discard block |
||
| 290 | 290 | Event::on( |
| 291 | 291 | Plugins::class, |
| 292 | 292 | Plugins::EVENT_AFTER_LOAD_PLUGINS, |
| 293 | - function () { |
|
| 293 | + function() { |
|
| 294 | 294 | // Install these only after all other plugins have loaded |
| 295 | 295 | $request = Craft::$app->getRequest(); |
| 296 | 296 | // Only respond to non-console site requests |
@@ -314,7 +314,7 @@ discard block |
||
| 314 | 314 | Event::on( |
| 315 | 315 | UrlManager::class, |
| 316 | 316 | UrlManager::EVENT_REGISTER_SITE_URL_RULES, |
| 317 | - function (RegisterUrlRulesEvent $event) { |
|
| 317 | + function(RegisterUrlRulesEvent $event) { |
|
| 318 | 318 | Craft::debug( |
| 319 | 319 | 'UrlManager::EVENT_REGISTER_SITE_URL_RULES', |
| 320 | 320 | __METHOD__ |
@@ -337,15 +337,15 @@ discard block |
||
| 337 | 337 | Event::on( |
| 338 | 338 | Dashboard::class, |
| 339 | 339 | Dashboard::EVENT_REGISTER_WIDGET_TYPES, |
| 340 | - function (RegisterComponentTypesEvent $event) { |
|
| 341 | - $event->types[] = RetourWidget::class; |
|
| 340 | + function(RegisterComponentTypesEvent $event) { |
|
| 341 | + $event->types[ ] = RetourWidget::class; |
|
| 342 | 342 | } |
| 343 | 343 | ); |
| 344 | 344 | // Handler: UrlManager::EVENT_REGISTER_CP_URL_RULES |
| 345 | 345 | Event::on( |
| 346 | 346 | UrlManager::class, |
| 347 | 347 | UrlManager::EVENT_REGISTER_CP_URL_RULES, |
| 348 | - function (RegisterUrlRulesEvent $event) { |
|
| 348 | + function(RegisterUrlRulesEvent $event) { |
|
| 349 | 349 | Craft::debug( |
| 350 | 350 | 'UrlManager::EVENT_REGISTER_CP_URL_RULES', |
| 351 | 351 | __METHOD__ |
@@ -361,20 +361,20 @@ discard block |
||
| 361 | 361 | Event::on( |
| 362 | 362 | UserPermissions::class, |
| 363 | 363 | UserPermissions::EVENT_REGISTER_PERMISSIONS, |
| 364 | - function (RegisterUserPermissionsEvent $event) { |
|
| 364 | + function(RegisterUserPermissionsEvent $event) { |
|
| 365 | 365 | Craft::debug( |
| 366 | 366 | 'UserPermissions::EVENT_REGISTER_PERMISSIONS', |
| 367 | 367 | __METHOD__ |
| 368 | 368 | ); |
| 369 | 369 | // Register our custom permissions |
| 370 | - $event->permissions[Craft::t('retour', 'Retour')] = $this->customAdminCpPermissions(); |
|
| 370 | + $event->permissions[ Craft::t('retour', 'Retour') ] = $this->customAdminCpPermissions(); |
|
| 371 | 371 | } |
| 372 | 372 | ); |
| 373 | 373 | // Handler: ClearCaches::EVENT_REGISTER_CACHE_OPTIONS |
| 374 | 374 | Event::on( |
| 375 | 375 | ClearCaches::class, |
| 376 | 376 | ClearCaches::EVENT_REGISTER_CACHE_OPTIONS, |
| 377 | - function (RegisterCacheOptionsEvent $event) { |
|
| 377 | + function(RegisterCacheOptionsEvent $event) { |
|
| 378 | 378 | Craft::debug( |
| 379 | 379 | 'ClearCaches::EVENT_REGISTER_CACHE_OPTIONS', |
| 380 | 380 | __METHOD__ |
@@ -399,7 +399,7 @@ discard block |
||
| 399 | 399 | Event::on( |
| 400 | 400 | ErrorHandler::class, |
| 401 | 401 | ErrorHandler::EVENT_BEFORE_HANDLE_EXCEPTION, |
| 402 | - function (ExceptionEvent $event) { |
|
| 402 | + function(ExceptionEvent $event) { |
|
| 403 | 403 | Craft::debug( |
| 404 | 404 | 'ErrorHandler::EVENT_BEFORE_HANDLE_EXCEPTION', |
| 405 | 405 | __METHOD__ |
@@ -441,16 +441,16 @@ discard block |
||
| 441 | 441 | protected function handleElementUriChange(Element $element) |
| 442 | 442 | { |
| 443 | 443 | $uris = $this->getAllElementUris($element); |
| 444 | - if (!empty($this->oldElementUris[$element->id])) { |
|
| 445 | - $oldElementUris = $this->oldElementUris[$element->id]; |
|
| 444 | + if (!empty($this->oldElementUris[ $element->id ])) { |
|
| 445 | + $oldElementUris = $this->oldElementUris[ $element->id ]; |
|
| 446 | 446 | foreach ($uris as $siteId => $newUri) { |
| 447 | - if (!empty($oldElementUris[$siteId])) { |
|
| 448 | - $oldUri = $oldElementUris[$siteId]; |
|
| 447 | + if (!empty($oldElementUris[ $siteId ])) { |
|
| 448 | + $oldUri = $oldElementUris[ $siteId ]; |
|
| 449 | 449 | Craft::debug( |
| 450 | 450 | Craft::t( |
| 451 | 451 | 'retour', |
| 452 | 452 | 'Comparing old: {oldUri} to new: {newUri}', |
| 453 | - ['oldUri' => print_r($oldUri, true), 'newUri' => print_r($newUri, true)] |
|
| 453 | + [ 'oldUri' => print_r($oldUri, true), 'newUri' => print_r($newUri, true) ] |
|
| 454 | 454 | ), |
| 455 | 455 | __METHOD__ |
| 456 | 456 | ); |
@@ -478,12 +478,12 @@ discard block |
||
| 478 | 478 | */ |
| 479 | 479 | protected function getAllElementUris(Element $element): array |
| 480 | 480 | { |
| 481 | - $uris = []; |
|
| 481 | + $uris = [ ]; |
|
| 482 | 482 | $sites = Craft::$app->getSites()->getAllSites(); |
| 483 | 483 | foreach ($sites as $site) { |
| 484 | 484 | $uri = Craft::$app->getElements()->getElementUriForSite($element->id, $site->id); |
| 485 | 485 | if ($uri !== null) { |
| 486 | - $uris[$site->id] = $uri; |
|
| 486 | + $uris[ $site->id ] = $uri; |
|
| 487 | 487 | } |
| 488 | 488 | } |
| 489 | 489 | |
@@ -491,7 +491,7 @@ discard block |
||
| 491 | 491 | Craft::t( |
| 492 | 492 | 'retour', |
| 493 | 493 | 'Getting Element URIs: {uris}', |
| 494 | - ['uris' => print_r($uris, true)] |
|
| 494 | + [ 'uris' => print_r($uris, true) ] |
|
| 495 | 495 | ), |
| 496 | 496 | __METHOD__ |
| 497 | 497 | ); |
@@ -558,7 +558,7 @@ discard block |
||
| 558 | 558 | [ |
| 559 | 559 | 'key' => 'retour-redirect-caches', |
| 560 | 560 | 'label' => Craft::t('retour', 'Retour redirect caches'), |
| 561 | - 'action' => [self::$plugin->redirects, 'invalidateCaches'], |
|
| 561 | + 'action' => [ self::$plugin->redirects, 'invalidateCaches' ], |
|
| 562 | 562 | ], |
| 563 | 563 | ]; |
| 564 | 564 | } |