@@ -62,36 +62,36 @@ discard block |
||
62 | 62 | // Boolean field |
63 | 63 | $retourField |
64 | 64 | ->addBooleanField($field) |
65 | - ->resolve(function ($redirect) use ($field) { |
|
66 | - $result = $redirect[$field] ?? null; |
|
67 | - return $result === null ? $result : (bool)$result; |
|
65 | + ->resolve(function($redirect) use ($field) { |
|
66 | + $result = $redirect[ $field ] ?? null; |
|
67 | + return $result === null ? $result : (bool) $result; |
|
68 | 68 | }); |
69 | 69 | } elseif (in_array($field, self::INT_FIELDS, true)) { |
70 | 70 | // Integer field |
71 | 71 | $retourField |
72 | 72 | ->addIntField($field) |
73 | - ->resolve(function ($redirect) use ($field) { |
|
74 | - $result = $redirect[$field] ?? null; |
|
75 | - return $result === null ? $result : (int)$result; |
|
73 | + ->resolve(function($redirect) use ($field) { |
|
74 | + $result = $redirect[ $field ] ?? null; |
|
75 | + return $result === null ? $result : (int) $result; |
|
76 | 76 | }); |
77 | 77 | } else { |
78 | 78 | // String field |
79 | 79 | $retourField |
80 | 80 | ->addStringField($field) |
81 | - ->resolve(function ($redirect) use ($field) { |
|
82 | - $result = $redirect[$field] ?? null; |
|
83 | - return $result === null ? $result : (string)$result; |
|
81 | + ->resolve(function($redirect) use ($field) { |
|
82 | + $result = $redirect[ $field ] ?? null; |
|
83 | + return $result === null ? $result : (string) $result; |
|
84 | 84 | }); |
85 | 85 | } |
86 | 86 | } |
87 | 87 | // Add the root |
88 | 88 | $event->schema->addField('retour') |
89 | - ->arguments(function (FieldBuilder $field) { |
|
89 | + ->arguments(function(FieldBuilder $field) { |
|
90 | 90 | $field->addStringArgument('uri'); |
91 | 91 | $field->addIntArgument('siteId'); |
92 | 92 | }) |
93 | 93 | ->type($retourField) |
94 | - ->resolve(function ($root, $args, $context, $info) { |
|
94 | + ->resolve(function($root, $args, $context, $info) { |
|
95 | 95 | // If our root is an Element, extract the URI and siteId from it |
96 | 96 | if ($root instanceof Element) { |
97 | 97 | /** Element $root */ |
@@ -99,8 +99,8 @@ discard block |
||
99 | 99 | $siteId = $root->siteId; |
100 | 100 | } else { |
101 | 101 | // Otherwise use the passed in arguments, or defaults |
102 | - $uri = $args['uri'] ?? '/'; |
|
103 | - $siteId = $args['siteId'] ?? null; |
|
102 | + $uri = $args[ 'uri' ] ?? '/'; |
|
103 | + $siteId = $args[ 'siteId' ] ?? null; |
|
104 | 104 | } |
105 | 105 | $uri = trim($uri === '/' ? '__home__' : $uri); |
106 | 106 |
@@ -104,7 +104,7 @@ discard block |
||
104 | 104 | /** |
105 | 105 | * @var array The URIs for the element before it was saved |
106 | 106 | */ |
107 | - public $oldElementUris = []; |
|
107 | + public $oldElementUris = [ ]; |
|
108 | 108 | |
109 | 109 | // Public Methods |
110 | 110 | // ========================================================================= |
@@ -135,7 +135,7 @@ discard block |
||
135 | 135 | Craft::t( |
136 | 136 | 'retour', |
137 | 137 | '{name} plugin loaded', |
138 | - ['name' => $this->name] |
|
138 | + [ 'name' => $this->name ] |
|
139 | 139 | ), |
140 | 140 | __METHOD__ |
141 | 141 | ); |
@@ -155,18 +155,18 @@ discard block |
||
155 | 155 | */ |
156 | 156 | public function getCpNavItem() |
157 | 157 | { |
158 | - $subNavs = []; |
|
158 | + $subNavs = [ ]; |
|
159 | 159 | $navItem = parent::getCpNavItem(); |
160 | 160 | $currentUser = Craft::$app->getUser()->getIdentity(); |
161 | 161 | // Only show sub-navs the user has permission to view |
162 | 162 | if ($currentUser->can('retour:dashboard')) { |
163 | - $subNavs['dashboard'] = [ |
|
163 | + $subNavs[ 'dashboard' ] = [ |
|
164 | 164 | 'label' => 'Dashboard', |
165 | 165 | 'url' => 'retour/dashboard', |
166 | 166 | ]; |
167 | 167 | } |
168 | 168 | if ($currentUser->can('retour:redirects')) { |
169 | - $subNavs['redirects'] = [ |
|
169 | + $subNavs[ 'redirects' ] = [ |
|
170 | 170 | 'label' => 'Redirects', |
171 | 171 | 'url' => 'retour/redirects', |
172 | 172 | ]; |
@@ -177,7 +177,7 @@ discard block |
||
177 | 177 | $editableSettings = false; |
178 | 178 | } |
179 | 179 | if ($currentUser->can('retour:settings') && $editableSettings) { |
180 | - $subNavs['settings'] = [ |
|
180 | + $subNavs[ 'settings' ] = [ |
|
181 | 181 | 'label' => 'Settings', |
182 | 182 | 'url' => 'retour/settings', |
183 | 183 | ]; |
@@ -236,7 +236,7 @@ discard block |
||
236 | 236 | Event::on( |
237 | 237 | ClearCaches::class, |
238 | 238 | ClearCaches::EVENT_REGISTER_CACHE_OPTIONS, |
239 | - function (RegisterCacheOptionsEvent $event) { |
|
239 | + function(RegisterCacheOptionsEvent $event) { |
|
240 | 240 | Craft::debug( |
241 | 241 | 'ClearCaches::EVENT_REGISTER_CACHE_OPTIONS', |
242 | 242 | __METHOD__ |
@@ -252,7 +252,7 @@ discard block |
||
252 | 252 | Event::on( |
253 | 253 | Plugins::class, |
254 | 254 | Plugins::EVENT_AFTER_INSTALL_PLUGIN, |
255 | - function (PluginEvent $event) { |
|
255 | + function(PluginEvent $event) { |
|
256 | 256 | if ($event->plugin === $this) { |
257 | 257 | // Invalidate our caches after we've been installed |
258 | 258 | $this->clearAllCaches(); |
@@ -279,7 +279,7 @@ discard block |
||
279 | 279 | Event::on( |
280 | 280 | CraftVariable::class, |
281 | 281 | CraftVariable::EVENT_INIT, |
282 | - function (Event $event) { |
|
282 | + function(Event $event) { |
|
283 | 283 | /** @var CraftVariable $variable */ |
284 | 284 | $variable = $event->sender; |
285 | 285 | $variable->set('retour', RetourVariable::class); |
@@ -289,7 +289,7 @@ discard block |
||
289 | 289 | Event::on( |
290 | 290 | Elements::class, |
291 | 291 | Elements::EVENT_BEFORE_SAVE_ELEMENT, |
292 | - function (ElementEvent $event) { |
|
292 | + function(ElementEvent $event) { |
|
293 | 293 | Craft::debug( |
294 | 294 | 'Elements::EVENT_BEFORE_SAVE_ELEMENT', |
295 | 295 | __METHOD__ |
@@ -304,8 +304,8 @@ discard block |
||
304 | 304 | if ($oldElement !== null) { |
305 | 305 | // Stash the old URLs by element id, and do so only once, |
306 | 306 | // in case we are called more than once per request |
307 | - if (empty($this->oldElementUris[$oldElement->id])) { |
|
308 | - $this->oldElementUris[$oldElement->id] = $this->getAllElementUris($oldElement); |
|
307 | + if (empty($this->oldElementUris[ $oldElement->id ])) { |
|
308 | + $this->oldElementUris[ $oldElement->id ] = $this->getAllElementUris($oldElement); |
|
309 | 309 | } |
310 | 310 | } |
311 | 311 | } |
@@ -316,7 +316,7 @@ discard block |
||
316 | 316 | Event::on( |
317 | 317 | Elements::class, |
318 | 318 | Elements::EVENT_AFTER_SAVE_ELEMENT, |
319 | - function (ElementEvent $event) { |
|
319 | + function(ElementEvent $event) { |
|
320 | 320 | Craft::debug( |
321 | 321 | 'Elements::EVENT_AFTER_SAVE_ELEMENT', |
322 | 322 | __METHOD__ |
@@ -332,7 +332,7 @@ discard block |
||
332 | 332 | Event::on( |
333 | 333 | Plugins::class, |
334 | 334 | Plugins::EVENT_AFTER_LOAD_PLUGINS, |
335 | - function () { |
|
335 | + function() { |
|
336 | 336 | // Install these only after all other plugins have loaded |
337 | 337 | $request = Craft::$app->getRequest(); |
338 | 338 | // Only respond to non-console site requests |
@@ -350,7 +350,7 @@ discard block |
||
350 | 350 | Event::on( |
351 | 351 | Schema::class, |
352 | 352 | AlterSchemaFields::EVENT, |
353 | - [GetCraftQLSchema::class, 'handle'] |
|
353 | + [ GetCraftQLSchema::class, 'handle' ] |
|
354 | 354 | ); |
355 | 355 | } |
356 | 356 | } |
@@ -364,7 +364,7 @@ discard block |
||
364 | 364 | Event::on( |
365 | 365 | UrlManager::class, |
366 | 366 | UrlManager::EVENT_REGISTER_SITE_URL_RULES, |
367 | - function (RegisterUrlRulesEvent $event) { |
|
367 | + function(RegisterUrlRulesEvent $event) { |
|
368 | 368 | Craft::debug( |
369 | 369 | 'UrlManager::EVENT_REGISTER_SITE_URL_RULES', |
370 | 370 | __METHOD__ |
@@ -387,15 +387,15 @@ discard block |
||
387 | 387 | Event::on( |
388 | 388 | Dashboard::class, |
389 | 389 | Dashboard::EVENT_REGISTER_WIDGET_TYPES, |
390 | - function (RegisterComponentTypesEvent $event) { |
|
391 | - $event->types[] = RetourWidget::class; |
|
390 | + function(RegisterComponentTypesEvent $event) { |
|
391 | + $event->types[ ] = RetourWidget::class; |
|
392 | 392 | } |
393 | 393 | ); |
394 | 394 | // Handler: UrlManager::EVENT_REGISTER_CP_URL_RULES |
395 | 395 | Event::on( |
396 | 396 | UrlManager::class, |
397 | 397 | UrlManager::EVENT_REGISTER_CP_URL_RULES, |
398 | - function (RegisterUrlRulesEvent $event) { |
|
398 | + function(RegisterUrlRulesEvent $event) { |
|
399 | 399 | Craft::debug( |
400 | 400 | 'UrlManager::EVENT_REGISTER_CP_URL_RULES', |
401 | 401 | __METHOD__ |
@@ -411,13 +411,13 @@ discard block |
||
411 | 411 | Event::on( |
412 | 412 | UserPermissions::class, |
413 | 413 | UserPermissions::EVENT_REGISTER_PERMISSIONS, |
414 | - function (RegisterUserPermissionsEvent $event) { |
|
414 | + function(RegisterUserPermissionsEvent $event) { |
|
415 | 415 | Craft::debug( |
416 | 416 | 'UserPermissions::EVENT_REGISTER_PERMISSIONS', |
417 | 417 | __METHOD__ |
418 | 418 | ); |
419 | 419 | // Register our custom permissions |
420 | - $event->permissions[Craft::t('retour', 'Retour')] = $this->customAdminCpPermissions(); |
|
420 | + $event->permissions[ Craft::t('retour', 'Retour') ] = $this->customAdminCpPermissions(); |
|
421 | 421 | } |
422 | 422 | ); |
423 | 423 | } |
@@ -433,7 +433,7 @@ discard block |
||
433 | 433 | Event::on( |
434 | 434 | ErrorHandler::class, |
435 | 435 | ErrorHandler::EVENT_BEFORE_HANDLE_EXCEPTION, |
436 | - function (ExceptionEvent $event) { |
|
436 | + function(ExceptionEvent $event) { |
|
437 | 437 | Craft::debug( |
438 | 438 | 'ErrorHandler::EVENT_BEFORE_HANDLE_EXCEPTION', |
439 | 439 | __METHOD__ |
@@ -476,16 +476,16 @@ discard block |
||
476 | 476 | protected function handleElementUriChange(Element $element) |
477 | 477 | { |
478 | 478 | $uris = $this->getAllElementUris($element); |
479 | - if (!empty($this->oldElementUris[$element->id])) { |
|
480 | - $oldElementUris = $this->oldElementUris[$element->id]; |
|
479 | + if (!empty($this->oldElementUris[ $element->id ])) { |
|
480 | + $oldElementUris = $this->oldElementUris[ $element->id ]; |
|
481 | 481 | foreach ($uris as $siteId => $newUri) { |
482 | - if (!empty($oldElementUris[$siteId])) { |
|
483 | - $oldUri = $oldElementUris[$siteId]; |
|
482 | + if (!empty($oldElementUris[ $siteId ])) { |
|
483 | + $oldUri = $oldElementUris[ $siteId ]; |
|
484 | 484 | Craft::debug( |
485 | 485 | Craft::t( |
486 | 486 | 'retour', |
487 | 487 | 'Comparing old: {oldUri} to new: {newUri}', |
488 | - ['oldUri' => print_r($oldUri, true), 'newUri' => print_r($newUri, true)] |
|
488 | + [ 'oldUri' => print_r($oldUri, true), 'newUri' => print_r($newUri, true) ] |
|
489 | 489 | ), |
490 | 490 | __METHOD__ |
491 | 491 | ); |
@@ -520,12 +520,12 @@ discard block |
||
520 | 520 | */ |
521 | 521 | protected function getAllElementUris(Element $element): array |
522 | 522 | { |
523 | - $uris = []; |
|
523 | + $uris = [ ]; |
|
524 | 524 | $sites = Craft::$app->getSites()->getAllSites(); |
525 | 525 | foreach ($sites as $site) { |
526 | 526 | $uri = Craft::$app->getElements()->getElementUriForSite($element->id, $site->id); |
527 | 527 | if ($uri !== null) { |
528 | - $uris[$site->id] = $uri; |
|
528 | + $uris[ $site->id ] = $uri; |
|
529 | 529 | } |
530 | 530 | } |
531 | 531 | |
@@ -533,7 +533,7 @@ discard block |
||
533 | 533 | Craft::t( |
534 | 534 | 'retour', |
535 | 535 | 'Getting Element URIs: {uris}', |
536 | - ['uris' => print_r($uris, true)] |
|
536 | + [ 'uris' => print_r($uris, true) ] |
|
537 | 537 | ), |
538 | 538 | __METHOD__ |
539 | 539 | ); |
@@ -597,7 +597,7 @@ discard block |
||
597 | 597 | [ |
598 | 598 | 'key' => 'retour-redirect-caches', |
599 | 599 | 'label' => Craft::t('retour', 'Retour redirect caches'), |
600 | - 'action' => [self::$plugin->redirects, 'invalidateCaches'], |
|
600 | + 'action' => [ self::$plugin->redirects, 'invalidateCaches' ], |
|
601 | 601 | ], |
602 | 602 | ]; |
603 | 603 | } |