@@ -121,7 +121,7 @@ discard block |
||
121 | 121 | /** |
122 | 122 | * @var array The URIs for the element before it was saved |
123 | 123 | */ |
124 | - public $oldElementUris = []; |
|
124 | + public $oldElementUris = [ ]; |
|
125 | 125 | |
126 | 126 | // Public Methods |
127 | 127 | // ========================================================================= |
@@ -154,7 +154,7 @@ discard block |
||
154 | 154 | Craft::t( |
155 | 155 | 'retour', |
156 | 156 | '{name} plugin loaded', |
157 | - ['name' => $this->name] |
|
157 | + [ 'name' => $this->name ] |
|
158 | 158 | ), |
159 | 159 | __METHOD__ |
160 | 160 | ); |
@@ -174,18 +174,18 @@ discard block |
||
174 | 174 | */ |
175 | 175 | public function getCpNavItem() |
176 | 176 | { |
177 | - $subNavs = []; |
|
177 | + $subNavs = [ ]; |
|
178 | 178 | $navItem = parent::getCpNavItem(); |
179 | 179 | $currentUser = Craft::$app->getUser()->getIdentity(); |
180 | 180 | // Only show sub-navs the user has permission to view |
181 | 181 | if ($currentUser->can('retour:dashboard')) { |
182 | - $subNavs['dashboard'] = [ |
|
182 | + $subNavs[ 'dashboard' ] = [ |
|
183 | 183 | 'label' => 'Dashboard', |
184 | 184 | 'url' => 'retour/dashboard', |
185 | 185 | ]; |
186 | 186 | } |
187 | 187 | if ($currentUser->can('retour:redirects')) { |
188 | - $subNavs['redirects'] = [ |
|
188 | + $subNavs[ 'redirects' ] = [ |
|
189 | 189 | 'label' => 'Redirects', |
190 | 190 | 'url' => 'retour/redirects', |
191 | 191 | ]; |
@@ -196,7 +196,7 @@ discard block |
||
196 | 196 | $editableSettings = false; |
197 | 197 | } |
198 | 198 | if ($currentUser->can('retour:settings') && $editableSettings) { |
199 | - $subNavs['settings'] = [ |
|
199 | + $subNavs[ 'settings' ] = [ |
|
200 | 200 | 'label' => 'Settings', |
201 | 201 | 'url' => 'retour/settings', |
202 | 202 | ]; |
@@ -255,7 +255,7 @@ discard block |
||
255 | 255 | Event::on( |
256 | 256 | ClearCaches::class, |
257 | 257 | ClearCaches::EVENT_REGISTER_CACHE_OPTIONS, |
258 | - function (RegisterCacheOptionsEvent $event) { |
|
258 | + function(RegisterCacheOptionsEvent $event) { |
|
259 | 259 | Craft::debug( |
260 | 260 | 'ClearCaches::EVENT_REGISTER_CACHE_OPTIONS', |
261 | 261 | __METHOD__ |
@@ -271,7 +271,7 @@ discard block |
||
271 | 271 | Event::on( |
272 | 272 | Plugins::class, |
273 | 273 | Plugins::EVENT_AFTER_INSTALL_PLUGIN, |
274 | - function (PluginEvent $event) { |
|
274 | + function(PluginEvent $event) { |
|
275 | 275 | if ($event->plugin === $this) { |
276 | 276 | // Invalidate our caches after we've been installed |
277 | 277 | $this->clearAllCaches(); |
@@ -298,7 +298,7 @@ discard block |
||
298 | 298 | Event::on( |
299 | 299 | CraftVariable::class, |
300 | 300 | CraftVariable::EVENT_INIT, |
301 | - function (Event $event) { |
|
301 | + function(Event $event) { |
|
302 | 302 | /** @var CraftVariable $variable */ |
303 | 303 | $variable = $event->sender; |
304 | 304 | $variable->set('retour', RetourVariable::class); |
@@ -308,7 +308,7 @@ discard block |
||
308 | 308 | Event::on( |
309 | 309 | Elements::class, |
310 | 310 | Elements::EVENT_BEFORE_SAVE_ELEMENT, |
311 | - function (ElementEvent $event) { |
|
311 | + function(ElementEvent $event) { |
|
312 | 312 | Craft::debug( |
313 | 313 | 'Elements::EVENT_BEFORE_SAVE_ELEMENT', |
314 | 314 | __METHOD__ |
@@ -333,8 +333,8 @@ discard block |
||
333 | 333 | if (strpos($element->uri, '__temp_') === false && !$element->propagating) { |
334 | 334 | // Stash the old URLs by element id, and do so only once, |
335 | 335 | // in case we are called more than once per request |
336 | - if (empty($this->oldElementUris[$element->id])) { |
|
337 | - $this->oldElementUris[$element->id] = $this->getAllElementUris($element); |
|
336 | + if (empty($this->oldElementUris[ $element->id ])) { |
|
337 | + $this->oldElementUris[ $element->id ] = $this->getAllElementUris($element); |
|
338 | 338 | } |
339 | 339 | } |
340 | 340 | } |
@@ -345,7 +345,7 @@ discard block |
||
345 | 345 | Event::on( |
346 | 346 | Elements::class, |
347 | 347 | Elements::EVENT_AFTER_SAVE_ELEMENT, |
348 | - function (ElementEvent $event) { |
|
348 | + function(ElementEvent $event) { |
|
349 | 349 | Craft::debug( |
350 | 350 | 'Elements::EVENT_AFTER_SAVE_ELEMENT', |
351 | 351 | __METHOD__ |
@@ -367,7 +367,7 @@ discard block |
||
367 | 367 | Event::on( |
368 | 368 | Plugins::class, |
369 | 369 | Plugins::EVENT_AFTER_LOAD_PLUGINS, |
370 | - function () { |
|
370 | + function() { |
|
371 | 371 | // Install these only after all other plugins have loaded |
372 | 372 | $request = Craft::$app->getRequest(); |
373 | 373 | // Only respond to non-console site requests |
@@ -385,26 +385,26 @@ discard block |
||
385 | 385 | Event::on( |
386 | 386 | Gql::class, |
387 | 387 | Gql::EVENT_REGISTER_GQL_TYPES, |
388 | - function (RegisterGqlTypesEvent $event) { |
|
388 | + function(RegisterGqlTypesEvent $event) { |
|
389 | 389 | Craft::debug( |
390 | 390 | 'Gql::EVENT_REGISTER_GQL_TYPES', |
391 | 391 | __METHOD__ |
392 | 392 | ); |
393 | - $event->types[] = RetourInterface::class; |
|
393 | + $event->types[ ] = RetourInterface::class; |
|
394 | 394 | } |
395 | 395 | ); |
396 | 396 | // Handler: Gql::EVENT_REGISTER_GQL_QUERIES |
397 | 397 | Event::on( |
398 | 398 | Gql::class, |
399 | 399 | Gql::EVENT_REGISTER_GQL_QUERIES, |
400 | - function (RegisterGqlQueriesEvent $event) { |
|
400 | + function(RegisterGqlQueriesEvent $event) { |
|
401 | 401 | Craft::debug( |
402 | 402 | 'Gql::EVENT_REGISTER_GQL_QUERIES', |
403 | 403 | __METHOD__ |
404 | 404 | ); |
405 | 405 | $queries = RetourQuery::getQueries(); |
406 | 406 | foreach ($queries as $key => $value) { |
407 | - $event->queries[$key] = $value; |
|
407 | + $event->queries[ $key ] = $value; |
|
408 | 408 | } |
409 | 409 | } |
410 | 410 | ); |
@@ -414,7 +414,7 @@ discard block |
||
414 | 414 | Event::on( |
415 | 415 | Schema::class, |
416 | 416 | AlterSchemaFields::EVENT, |
417 | - [GetCraftQLSchema::class, 'handle'] |
|
417 | + [ GetCraftQLSchema::class, 'handle' ] |
|
418 | 418 | ); |
419 | 419 | } |
420 | 420 | } |
@@ -428,7 +428,7 @@ discard block |
||
428 | 428 | Event::on( |
429 | 429 | UrlManager::class, |
430 | 430 | UrlManager::EVENT_REGISTER_SITE_URL_RULES, |
431 | - function (RegisterUrlRulesEvent $event) { |
|
431 | + function(RegisterUrlRulesEvent $event) { |
|
432 | 432 | Craft::debug( |
433 | 433 | 'UrlManager::EVENT_REGISTER_SITE_URL_RULES', |
434 | 434 | __METHOD__ |
@@ -451,15 +451,15 @@ discard block |
||
451 | 451 | Event::on( |
452 | 452 | Dashboard::class, |
453 | 453 | Dashboard::EVENT_REGISTER_WIDGET_TYPES, |
454 | - function (RegisterComponentTypesEvent $event) { |
|
455 | - $event->types[] = RetourWidget::class; |
|
454 | + function(RegisterComponentTypesEvent $event) { |
|
455 | + $event->types[ ] = RetourWidget::class; |
|
456 | 456 | } |
457 | 457 | ); |
458 | 458 | // Handler: UrlManager::EVENT_REGISTER_CP_URL_RULES |
459 | 459 | Event::on( |
460 | 460 | UrlManager::class, |
461 | 461 | UrlManager::EVENT_REGISTER_CP_URL_RULES, |
462 | - function (RegisterUrlRulesEvent $event) { |
|
462 | + function(RegisterUrlRulesEvent $event) { |
|
463 | 463 | Craft::debug( |
464 | 464 | 'UrlManager::EVENT_REGISTER_CP_URL_RULES', |
465 | 465 | __METHOD__ |
@@ -475,13 +475,13 @@ discard block |
||
475 | 475 | Event::on( |
476 | 476 | UserPermissions::class, |
477 | 477 | UserPermissions::EVENT_REGISTER_PERMISSIONS, |
478 | - function (RegisterUserPermissionsEvent $event) { |
|
478 | + function(RegisterUserPermissionsEvent $event) { |
|
479 | 479 | Craft::debug( |
480 | 480 | 'UserPermissions::EVENT_REGISTER_PERMISSIONS', |
481 | 481 | __METHOD__ |
482 | 482 | ); |
483 | 483 | // Register our custom permissions |
484 | - $event->permissions[Craft::t('retour', 'Retour')] = $this->customAdminCpPermissions(); |
|
484 | + $event->permissions[ Craft::t('retour', 'Retour') ] = $this->customAdminCpPermissions(); |
|
485 | 485 | } |
486 | 486 | ); |
487 | 487 | } |
@@ -497,7 +497,7 @@ discard block |
||
497 | 497 | Event::on( |
498 | 498 | ErrorHandler::class, |
499 | 499 | ErrorHandler::EVENT_BEFORE_HANDLE_EXCEPTION, |
500 | - function (ExceptionEvent $event) { |
|
500 | + function(ExceptionEvent $event) { |
|
501 | 501 | Craft::debug( |
502 | 502 | 'ErrorHandler::EVENT_BEFORE_HANDLE_EXCEPTION', |
503 | 503 | __METHOD__ |
@@ -540,16 +540,16 @@ discard block |
||
540 | 540 | protected function handleElementUriChange(Element $element) |
541 | 541 | { |
542 | 542 | $uris = $this->getAllElementUris($element); |
543 | - if (!empty($this->oldElementUris[$element->id])) { |
|
544 | - $oldElementUris = $this->oldElementUris[$element->id]; |
|
543 | + if (!empty($this->oldElementUris[ $element->id ])) { |
|
544 | + $oldElementUris = $this->oldElementUris[ $element->id ]; |
|
545 | 545 | foreach ($uris as $siteId => $newUri) { |
546 | - if (!empty($oldElementUris[$siteId])) { |
|
547 | - $oldUri = $oldElementUris[$siteId]; |
|
546 | + if (!empty($oldElementUris[ $siteId ])) { |
|
547 | + $oldUri = $oldElementUris[ $siteId ]; |
|
548 | 548 | Craft::debug( |
549 | 549 | Craft::t( |
550 | 550 | 'retour', |
551 | 551 | 'Comparing old: {oldUri} to new: {newUri}', |
552 | - ['oldUri' => print_r($oldUri, true), 'newUri' => print_r($newUri, true)] |
|
552 | + [ 'oldUri' => print_r($oldUri, true), 'newUri' => print_r($newUri, true) ] |
|
553 | 553 | ), |
554 | 554 | __METHOD__ |
555 | 555 | ); |
@@ -599,13 +599,13 @@ discard block |
||
599 | 599 | */ |
600 | 600 | protected function getAllElementUris(Element $element): array |
601 | 601 | { |
602 | - $uris = []; |
|
602 | + $uris = [ ]; |
|
603 | 603 | if (!self::$craft32 || !ElementHelper::isDraftOrRevision($element)) { |
604 | 604 | $sites = Craft::$app->getSites()->getAllSites(); |
605 | 605 | foreach ($sites as $site) { |
606 | 606 | $uri = Craft::$app->getElements()->getElementUriForSite($element->id, $site->id); |
607 | 607 | if ($uri !== null) { |
608 | - $uris[$site->id] = $uri; |
|
608 | + $uris[ $site->id ] = $uri; |
|
609 | 609 | } |
610 | 610 | } |
611 | 611 | } |
@@ -614,7 +614,7 @@ discard block |
||
614 | 614 | Craft::t( |
615 | 615 | 'retour', |
616 | 616 | 'Getting Element URIs: {uris}', |
617 | - ['uris' => print_r($uris, true)] |
|
617 | + [ 'uris' => print_r($uris, true) ] |
|
618 | 618 | ), |
619 | 619 | __METHOD__ |
620 | 620 | ); |
@@ -671,7 +671,7 @@ discard block |
||
671 | 671 | [ |
672 | 672 | 'key' => 'retour-redirect-caches', |
673 | 673 | 'label' => Craft::t('retour', 'Retour redirect caches'), |
674 | - 'action' => [self::$plugin->redirects, 'invalidateCaches'], |
|
674 | + 'action' => [ self::$plugin->redirects, 'invalidateCaches' ], |
|
675 | 675 | ], |
676 | 676 | ]; |
677 | 677 | } |
@@ -31,7 +31,7 @@ discard block |
||
31 | 31 | */ |
32 | 32 | public function __construct(array $config) |
33 | 33 | { |
34 | - $config['interfaces'] = [ |
|
34 | + $config[ 'interfaces' ] = [ |
|
35 | 35 | RetourInterface::getType(), |
36 | 36 | ]; |
37 | 37 | |
@@ -45,6 +45,6 @@ discard block |
||
45 | 45 | { |
46 | 46 | $fieldName = $resolveInfo->fieldName; |
47 | 47 | |
48 | - return $source[$fieldName]; |
|
48 | + return $source[ $fieldName ]; |
|
49 | 49 | } |
50 | 50 | } |
@@ -40,20 +40,20 @@ |
||
40 | 40 | $retourType = GqlEntityRegistry::getEntity($typeName) |
41 | 41 | ?: GqlEntityRegistry::createEntity($typeName, new RetourType([ |
42 | 42 | 'name' => $typeName, |
43 | - 'args' => function () use ($retourArgs) { |
|
43 | + 'args' => function() use ($retourArgs) { |
|
44 | 44 | return $retourArgs; |
45 | 45 | }, |
46 | - 'fields' => function () use ($retourFields) { |
|
46 | + 'fields' => function() use ($retourFields) { |
|
47 | 47 | return $retourFields; |
48 | 48 | }, |
49 | 49 | 'description' => 'This entity has all the Retour fields', |
50 | 50 | ])); |
51 | 51 | |
52 | - TypeLoader::registerType($typeName, function () use ($retourType) { |
|
52 | + TypeLoader::registerType($typeName, function() use ($retourType) { |
|
53 | 53 | return $retourType; |
54 | 54 | }); |
55 | 55 | |
56 | - return [$retourType]; |
|
56 | + return [ $retourType ]; |
|
57 | 57 | } |
58 | 58 | |
59 | 59 | /** |
@@ -48,15 +48,15 @@ |
||
48 | 48 | |
49 | 49 | $type = GqlEntityRegistry::createEntity(self::class, new InterfaceType([ |
50 | 50 | 'name' => static::getName(), |
51 | - 'fields' => self::class.'::getFieldDefinitions', |
|
51 | + 'fields' => self::class . '::getFieldDefinitions', |
|
52 | 52 | 'description' => 'This is the interface implemented by Retour.', |
53 | - 'resolveType' => function (array $value) { |
|
53 | + 'resolveType' => function(array $value) { |
|
54 | 54 | return GqlEntityRegistry::getEntity(RetourGenerator::getName()); |
55 | 55 | }, |
56 | 56 | ])); |
57 | 57 | |
58 | 58 | foreach (RetourGenerator::generateTypes() as $typeName => $generatedType) { |
59 | - TypeLoader::registerType($typeName, function () use ($generatedType) { |
|
59 | + TypeLoader::registerType($typeName, function() use ($generatedType) { |
|
60 | 60 | return $generatedType; |
61 | 61 | }); |
62 | 62 | } |
@@ -40,8 +40,8 @@ |
||
40 | 40 | $siteId = $source->siteId; |
41 | 41 | } else { |
42 | 42 | // Otherwise use the passed in arguments, or defaults |
43 | - $uri = $arguments['uri'] ?? '/'; |
|
44 | - $siteId = $arguments['siteId'] ?? null; |
|
43 | + $uri = $arguments[ 'uri' ] ?? '/'; |
|
44 | + $siteId = $arguments[ 'siteId' ] ?? null; |
|
45 | 45 | } |
46 | 46 | $uri = trim($uri === '/' ? '__home__' : $uri); |
47 | 47 |