@@ -285,7 +285,7 @@ discard block |
||
| 285 | 285 | Event::on( |
| 286 | 286 | ClearCaches::class, |
| 287 | 287 | ClearCaches::EVENT_REGISTER_CACHE_OPTIONS, |
| 288 | - function (RegisterCacheOptionsEvent $event) { |
|
| 288 | + function(RegisterCacheOptionsEvent $event) { |
|
| 289 | 289 | Craft::debug( |
| 290 | 290 | 'ClearCaches::EVENT_REGISTER_CACHE_OPTIONS', |
| 291 | 291 | __METHOD__ |
@@ -301,7 +301,7 @@ discard block |
||
| 301 | 301 | Event::on( |
| 302 | 302 | Plugins::class, |
| 303 | 303 | Plugins::EVENT_AFTER_INSTALL_PLUGIN, |
| 304 | - function (PluginEvent $event) { |
|
| 304 | + function(PluginEvent $event) { |
|
| 305 | 305 | if ($event->plugin === $this) { |
| 306 | 306 | // Invalidate our caches after we've been installed |
| 307 | 307 | $this->clearAllCaches(); |
@@ -328,7 +328,7 @@ discard block |
||
| 328 | 328 | Event::on( |
| 329 | 329 | CraftVariable::class, |
| 330 | 330 | CraftVariable::EVENT_INIT, |
| 331 | - function (Event $event) { |
|
| 331 | + function(Event $event) { |
|
| 332 | 332 | /** @var CraftVariable $variable */ |
| 333 | 333 | $variable = $event->sender; |
| 334 | 334 | $variable->set('retour', [ |
@@ -338,7 +338,7 @@ discard block |
||
| 338 | 338 | } |
| 339 | 339 | ); |
| 340 | 340 | |
| 341 | - $prepareRedirectOnElementChange = function (ElementEvent $event) { |
|
| 341 | + $prepareRedirectOnElementChange = function(ElementEvent $event) { |
|
| 342 | 342 | /** @var Element $element */ |
| 343 | 343 | $element = $event->element; |
| 344 | 344 | if ($element !== null && !$element->propagating && !$event->isNew && $element->getUrl() !== null) { |
@@ -361,7 +361,7 @@ discard block |
||
| 361 | 361 | } |
| 362 | 362 | }; |
| 363 | 363 | |
| 364 | - $insertRedirectOnElementChange = function (ElementEvent $event) { |
|
| 364 | + $insertRedirectOnElementChange = function(ElementEvent $event) { |
|
| 365 | 365 | /** @var Element $element */ |
| 366 | 366 | $element = $event->element; |
| 367 | 367 | if ($element !== null && !$event->isNew && $element->getUrl() !== null) { |
@@ -379,7 +379,7 @@ discard block |
||
| 379 | 379 | Event::on( |
| 380 | 380 | Elements::class, |
| 381 | 381 | Elements::EVENT_BEFORE_SAVE_ELEMENT, |
| 382 | - function (ElementEvent $event) use ($prepareRedirectOnElementChange) { |
|
| 382 | + function(ElementEvent $event) use ($prepareRedirectOnElementChange) { |
|
| 383 | 383 | Craft::debug( |
| 384 | 384 | 'Elements::EVENT_BEFORE_SAVE_ELEMENT', |
| 385 | 385 | __METHOD__ |
@@ -391,7 +391,7 @@ discard block |
||
| 391 | 391 | Event::on( |
| 392 | 392 | Elements::class, |
| 393 | 393 | Elements::EVENT_AFTER_SAVE_ELEMENT, |
| 394 | - function (ElementEvent $event) use ($insertRedirectOnElementChange) { |
|
| 394 | + function(ElementEvent $event) use ($insertRedirectOnElementChange) { |
|
| 395 | 395 | Craft::debug( |
| 396 | 396 | 'Elements::EVENT_AFTER_SAVE_ELEMENT', |
| 397 | 397 | __METHOD__ |
@@ -403,7 +403,7 @@ discard block |
||
| 403 | 403 | Event::on( |
| 404 | 404 | Elements::class, |
| 405 | 405 | Elements::EVENT_BEFORE_UPDATE_SLUG_AND_URI, |
| 406 | - function (ElementEvent $event) use ($prepareRedirectOnElementChange) { |
|
| 406 | + function(ElementEvent $event) use ($prepareRedirectOnElementChange) { |
|
| 407 | 407 | Craft::debug( |
| 408 | 408 | 'Elements::EVENT_BEFORE_UPDATE_SLUG_AND_URI', |
| 409 | 409 | __METHOD__ |
@@ -415,7 +415,7 @@ discard block |
||
| 415 | 415 | Event::on( |
| 416 | 416 | Elements::class, |
| 417 | 417 | Elements::EVENT_AFTER_UPDATE_SLUG_AND_URI, |
| 418 | - function (ElementEvent $event) use ($insertRedirectOnElementChange) { |
|
| 418 | + function(ElementEvent $event) use ($insertRedirectOnElementChange) { |
|
| 419 | 419 | Craft::debug( |
| 420 | 420 | 'Elements::EVENT_AFTER_UPDATE_SLUG_AND_URI', |
| 421 | 421 | __METHOD__ |
@@ -428,7 +428,7 @@ discard block |
||
| 428 | 428 | Event::on( |
| 429 | 429 | Plugins::class, |
| 430 | 430 | Plugins::EVENT_AFTER_LOAD_PLUGINS, |
| 431 | - function () { |
|
| 431 | + function() { |
|
| 432 | 432 | // Install these only after all other plugins have loaded |
| 433 | 433 | $request = Craft::$app->getRequest(); |
| 434 | 434 | // Only respond to non-console site requests |
@@ -445,7 +445,7 @@ discard block |
||
| 445 | 445 | Event::on( |
| 446 | 446 | Fields::class, |
| 447 | 447 | Fields::EVENT_REGISTER_FIELD_TYPES, |
| 448 | - function (RegisterComponentTypesEvent $event) { |
|
| 448 | + function(RegisterComponentTypesEvent $event) { |
|
| 449 | 449 | $event->types[] = ShortLinkField::class; |
| 450 | 450 | } |
| 451 | 451 | ); |
@@ -454,7 +454,7 @@ discard block |
||
| 454 | 454 | Event::on( |
| 455 | 455 | Gql::class, |
| 456 | 456 | Gql::EVENT_REGISTER_GQL_TYPES, |
| 457 | - function (RegisterGqlTypesEvent $event) { |
|
| 457 | + function(RegisterGqlTypesEvent $event) { |
|
| 458 | 458 | Craft::debug( |
| 459 | 459 | 'Gql::EVENT_REGISTER_GQL_TYPES', |
| 460 | 460 | __METHOD__ |
@@ -466,7 +466,7 @@ discard block |
||
| 466 | 466 | Event::on( |
| 467 | 467 | Gql::class, |
| 468 | 468 | Gql::EVENT_REGISTER_GQL_QUERIES, |
| 469 | - function (RegisterGqlQueriesEvent $event) { |
|
| 469 | + function(RegisterGqlQueriesEvent $event) { |
|
| 470 | 470 | Craft::debug( |
| 471 | 471 | 'Gql::EVENT_REGISTER_GQL_QUERIES', |
| 472 | 472 | __METHOD__ |
@@ -482,7 +482,7 @@ discard block |
||
| 482 | 482 | Event::on( |
| 483 | 483 | Gql::class, |
| 484 | 484 | Gql::EVENT_REGISTER_GQL_SCHEMA_COMPONENTS, |
| 485 | - function (RegisterGqlSchemaComponentsEvent $event) { |
|
| 485 | + function(RegisterGqlSchemaComponentsEvent $event) { |
|
| 486 | 486 | Craft::debug( |
| 487 | 487 | 'Gql::EVENT_REGISTER_GQL_SCHEMA_COMPONENTS', |
| 488 | 488 | __METHOD__ |
@@ -512,7 +512,7 @@ discard block |
||
| 512 | 512 | Event::on( |
| 513 | 513 | UrlManager::class, |
| 514 | 514 | UrlManager::EVENT_REGISTER_SITE_URL_RULES, |
| 515 | - function (RegisterUrlRulesEvent $event) { |
|
| 515 | + function(RegisterUrlRulesEvent $event) { |
|
| 516 | 516 | Craft::debug( |
| 517 | 517 | 'UrlManager::EVENT_REGISTER_SITE_URL_RULES', |
| 518 | 518 | __METHOD__ |
@@ -535,7 +535,7 @@ discard block |
||
| 535 | 535 | Event::on( |
| 536 | 536 | Dashboard::class, |
| 537 | 537 | Dashboard::EVENT_REGISTER_WIDGET_TYPES, |
| 538 | - function (RegisterComponentTypesEvent $event) { |
|
| 538 | + function(RegisterComponentTypesEvent $event) { |
|
| 539 | 539 | /** @var User $user */ |
| 540 | 540 | $user = Craft::$app->getUser(); |
| 541 | 541 | if ($currentUser = $user->getIdentity()) { |
@@ -549,7 +549,7 @@ discard block |
||
| 549 | 549 | Event::on( |
| 550 | 550 | UrlManager::class, |
| 551 | 551 | UrlManager::EVENT_REGISTER_CP_URL_RULES, |
| 552 | - function (RegisterUrlRulesEvent $event) { |
|
| 552 | + function(RegisterUrlRulesEvent $event) { |
|
| 553 | 553 | Craft::debug( |
| 554 | 554 | 'UrlManager::EVENT_REGISTER_CP_URL_RULES', |
| 555 | 555 | __METHOD__ |
@@ -565,7 +565,7 @@ discard block |
||
| 565 | 565 | Event::on( |
| 566 | 566 | UserPermissions::class, |
| 567 | 567 | UserPermissions::EVENT_REGISTER_PERMISSIONS, |
| 568 | - function (RegisterUserPermissionsEvent $event) { |
|
| 568 | + function(RegisterUserPermissionsEvent $event) { |
|
| 569 | 569 | Craft::debug( |
| 570 | 570 | 'UserPermissions::EVENT_REGISTER_PERMISSIONS', |
| 571 | 571 | __METHOD__ |
@@ -587,7 +587,7 @@ discard block |
||
| 587 | 587 | Event::on( |
| 588 | 588 | ErrorHandler::class, |
| 589 | 589 | ErrorHandler::EVENT_BEFORE_HANDLE_EXCEPTION, |
| 590 | - function (ExceptionEvent $event) { |
|
| 590 | + function(ExceptionEvent $event) { |
|
| 591 | 591 | Craft::debug( |
| 592 | 592 | 'ErrorHandler::EVENT_BEFORE_HANDLE_EXCEPTION', |
| 593 | 593 | __METHOD__ |
@@ -39,8 +39,8 @@ discard block |
||
| 39 | 39 | // Constants aren't allowed in traits until PHP >= 8.2 |
| 40 | 40 | $majorVersion = '3'; |
| 41 | 41 | // Dev server container name & port are based on the major version of this plugin |
| 42 | - $devPort = 3000 + (int)$majorVersion; |
|
| 43 | - $versionName = 'v' . $majorVersion; |
|
| 42 | + $devPort = 3000 + (int) $majorVersion; |
|
| 43 | + $versionName = 'v'.$majorVersion; |
|
| 44 | 44 | // Merge in the passed config, so it our config can be overridden by Plugins::pluginConfigs['retour'] |
| 45 | 45 | // ref: https://github.com/craftcms/cms/issues/1989 |
| 46 | 46 | $config = ArrayHelper::merge([ |
@@ -53,8 +53,8 @@ discard block |
||
| 53 | 53 | 'assetClass' => RetourAsset::class, |
| 54 | 54 | 'checkDevServer' => true, |
| 55 | 55 | 'class' => VitePluginService::class, |
| 56 | - 'devServerInternal' => 'http://craft-retour-' . $versionName . '-buildchain-dev:' . $devPort, |
|
| 57 | - 'devServerPublic' => 'http://localhost:' . $devPort, |
|
| 56 | + 'devServerInternal' => 'http://craft-retour-'.$versionName.'-buildchain-dev:'.$devPort, |
|
| 57 | + 'devServerPublic' => 'http://localhost:'.$devPort, |
|
| 58 | 58 | 'errorEntry' => 'src/js/Retour.js', |
| 59 | 59 | 'useDevServer' => true, |
| 60 | 60 | ], |
@@ -64,7 +64,7 @@ discard block |
||
| 64 | 64 | ->addBooleanField($field) |
| 65 | 65 | ->resolve(function($redirect) use ($field) { |
| 66 | 66 | $result = $redirect[$field] ?? null; |
| 67 | - return $result === null ? $result : (bool)$result; |
|
| 67 | + return $result === null ? $result : (bool) $result; |
|
| 68 | 68 | }); |
| 69 | 69 | } elseif (in_array($field, self::INT_FIELDS, true)) { |
| 70 | 70 | // Integer field |
@@ -72,7 +72,7 @@ discard block |
||
| 72 | 72 | ->addIntField($field) |
| 73 | 73 | ->resolve(function($redirect) use ($field) { |
| 74 | 74 | $result = $redirect[$field] ?? null; |
| 75 | - return $result === null ? $result : (int)$result; |
|
| 75 | + return $result === null ? $result : (int) $result; |
|
| 76 | 76 | }); |
| 77 | 77 | } else { |
| 78 | 78 | // String field |
@@ -80,7 +80,7 @@ discard block |
||
| 80 | 80 | ->addStringField($field) |
| 81 | 81 | ->resolve(function($redirect) use ($field) { |
| 82 | 82 | $result = $redirect[$field] ?? null; |
| 83 | - return $result === null ? $result : (string)$result; |
|
| 83 | + return $result === null ? $result : (string) $result; |
|
| 84 | 84 | }); |
| 85 | 85 | } |
| 86 | 86 | } |
@@ -47,7 +47,7 @@ |
||
| 47 | 47 | |
| 48 | 48 | $type = GqlEntityRegistry::createEntity(self::class, new InterfaceType([ |
| 49 | 49 | 'name' => static::getName(), |
| 50 | - 'fields' => self::class . '::getFieldDefinitions', |
|
| 50 | + 'fields' => self::class.'::getFieldDefinitions', |
|
| 51 | 51 | 'description' => 'This is the interface implemented by Retour.', |
| 52 | 52 | 'resolveType' => function(array $value) { |
| 53 | 53 | return GqlEntityRegistry::getEntity(RetourGenerator::getName()); |
@@ -41,14 +41,14 @@ discard block |
||
| 41 | 41 | 'retour' => [ |
| 42 | 42 | 'type' => RetourInterface::getType(), |
| 43 | 43 | 'args' => RetourArguments::getArguments(), |
| 44 | - 'resolve' => RetourResolver::class . '::resolve', |
|
| 44 | + 'resolve' => RetourResolver::class.'::resolve', |
|
| 45 | 45 | 'description' => 'This query is used to query for Retour redirects.', |
| 46 | 46 | 'deprecationReason' => 'This query is deprecated and will be removed in the future. You should use `retourResolveRedirect` instead.', |
| 47 | 47 | ], |
| 48 | 48 | 'retourResolveRedirect' => [ |
| 49 | 49 | 'type' => RetourInterface::getType(), |
| 50 | 50 | 'args' => RetourArguments::getArguments(), |
| 51 | - 'resolve' => RetourResolver::class . '::resolve', |
|
| 51 | + 'resolve' => RetourResolver::class.'::resolve', |
|
| 52 | 52 | 'description' => 'This query is used to query for Retour redirects.', |
| 53 | 53 | ], |
| 54 | 54 | 'retourRedirects' => [ |
@@ -65,7 +65,7 @@ discard block |
||
| 65 | 65 | 'description' => 'The siteId to list all redirects for.', |
| 66 | 66 | ], |
| 67 | 67 | ], |
| 68 | - 'resolve' => RetourResolver::class . '::resolveAll', |
|
| 68 | + 'resolve' => RetourResolver::class.'::resolveAll', |
|
| 69 | 69 | 'description' => 'This query is used to query for all Retour redirects for a site.', |
| 70 | 70 | ], |
| 71 | 71 | ]; |
@@ -65,8 +65,8 @@ |
||
| 65 | 65 | // Set the `site` virtual field |
| 66 | 66 | $redirect['site'] = null; |
| 67 | 67 | $redirect['siteId'] = $siteId; |
| 68 | - if (isset($redirect['siteId']) && (int)$redirect['siteId'] !== 0) { |
|
| 69 | - $site = Craft::$app->getSites()->getSiteById((int)$redirect['siteId']); |
|
| 68 | + if (isset($redirect['siteId']) && (int) $redirect['siteId'] !== 0) { |
|
| 69 | + $site = Craft::$app->getSites()->getSiteById((int) $redirect['siteId']); |
|
| 70 | 70 | if ($site !== null) { |
| 71 | 71 | $redirect['site'] = $site->handle; |
| 72 | 72 | } |
@@ -202,7 +202,7 @@ discard block |
||
| 202 | 202 | $variables['docsUrl'] = self::DOCUMENTATION_URL; |
| 203 | 203 | $variables['pluginName'] = $pluginName; |
| 204 | 204 | $variables['title'] = $templateTitle; |
| 205 | - $siteHandleUri = Craft::$app->isMultiSite ? '/' . $siteHandle : ''; |
|
| 205 | + $siteHandleUri = Craft::$app->isMultiSite ? '/'.$siteHandle : ''; |
|
| 206 | 206 | $variables['crumbs'] = [ |
| 207 | 207 | [ |
| 208 | 208 | 'label' => $pluginName, |
@@ -210,7 +210,7 @@ discard block |
||
| 210 | 210 | ], |
| 211 | 211 | [ |
| 212 | 212 | 'label' => 'Redirects', |
| 213 | - 'url' => UrlHelper::cpUrl('retour/redirects' . $siteHandleUri), |
|
| 213 | + 'url' => UrlHelper::cpUrl('retour/redirects'.$siteHandleUri), |
|
| 214 | 214 | ], |
| 215 | 215 | ]; |
| 216 | 216 | $variables['docTitle'] = "{$pluginName} - Redirects - {$templateTitle}"; |
@@ -220,7 +220,7 @@ discard block |
||
| 220 | 220 | $file = UploadedFile::getInstanceByName('file'); |
| 221 | 221 | if ($file !== null) { |
| 222 | 222 | $filename = uniqid($file->name, true); |
| 223 | - $filePath = Craft::$app->getPath()->getTempPath() . DIRECTORY_SEPARATOR . $filename; |
|
| 223 | + $filePath = Craft::$app->getPath()->getTempPath().DIRECTORY_SEPARATOR.$filename; |
|
| 224 | 224 | $file->saveAs($filePath, false); |
| 225 | 225 | // Also save the file to the cache as a backup way to access it |
| 226 | 226 | $fileContents = @file_get_contents($filePath); |
@@ -353,7 +353,7 @@ discard block |
||
| 353 | 353 | } |
| 354 | 354 | $csv->insertOne(array_values($columns)); |
| 355 | 355 | $csv->insertAll($data); |
| 356 | - $csv->output($filename . '.csv'); |
|
| 356 | + $csv->output($filename.'.csv'); |
|
| 357 | 357 | exit(0); |
| 358 | 358 | } |
| 359 | 359 | |
@@ -371,7 +371,7 @@ discard block |
||
| 371 | 371 | $columns = ArrayHelper::filterEmptyStringsFromArray($columns); |
| 372 | 372 | $rowIndex = 1; |
| 373 | 373 | /** @phpstan-ignore-next-line */ |
| 374 | - $csv->each(function ($row) use ($headers, $columns, &$rowIndex, &$hasErrors) { |
|
| 374 | + $csv->each(function($row) use ($headers, $columns, &$rowIndex, &$hasErrors) { |
|
| 375 | 375 | $redirectConfig = [ |
| 376 | 376 | 'id' => 0, |
| 377 | 377 | ]; |
@@ -385,9 +385,9 @@ discard block |
||
| 385 | 385 | $index++; |
| 386 | 386 | } |
| 387 | 387 | $redirectDump = print_r($redirectConfig, true); |
| 388 | - Craft::debug("-> ROW #$rowIndex contents: " . $redirectDump, __METHOD__); |
|
| 388 | + Craft::debug("-> ROW #$rowIndex contents: ".$redirectDump, __METHOD__); |
|
| 389 | 389 | if (!Retour::$plugin->redirects->saveRedirect($redirectConfig)) { |
| 390 | - Craft::info("-> ROW #$rowIndex contents: " . $redirectDump, __METHOD__); |
|
| 390 | + Craft::info("-> ROW #$rowIndex contents: ".$redirectDump, __METHOD__); |
|
| 391 | 391 | $hasErrors = true; |
| 392 | 392 | } |
| 393 | 393 | $rowIndex++; |
@@ -427,9 +427,9 @@ discard block |
||
| 427 | 427 | $index++; |
| 428 | 428 | } |
| 429 | 429 | $redirectDump = print_r($redirectConfig, true); |
| 430 | - Craft::debug("-> ROW #$rowIndex contents: " . $redirectDump, __METHOD__); |
|
| 430 | + Craft::debug("-> ROW #$rowIndex contents: ".$redirectDump, __METHOD__); |
|
| 431 | 431 | if (!Retour::$plugin->redirects->saveRedirect($redirectConfig)) { |
| 432 | - Craft::info("-> ROW #$rowIndex contents: " . $redirectDump, __METHOD__); |
|
| 432 | + Craft::info("-> ROW #$rowIndex contents: ".$redirectDump, __METHOD__); |
|
| 433 | 433 | $hasErrors = true; |
| 434 | 434 | } |
| 435 | 435 | $rowIndex++; |
@@ -87,7 +87,7 @@ discard block |
||
| 87 | 87 | $siteId = reset($variables['enabledSiteIds']); |
| 88 | 88 | } |
| 89 | 89 | } else { |
| 90 | - self::requirePermission('editSite:' . $siteId); |
|
| 90 | + self::requirePermission('editSite:'.$siteId); |
|
| 91 | 91 | } |
| 92 | 92 | } |
| 93 | 93 | } |
@@ -112,7 +112,7 @@ discard block |
||
| 112 | 112 | } else { |
| 113 | 113 | $variables['sitesMenuLabel'] = Craft::t( |
| 114 | 114 | 'site', |
| 115 | - $sites->getSiteById((int)$variables['currentSiteId'])->name |
|
| 115 | + $sites->getSiteById((int) $variables['currentSiteId'])->name |
|
| 116 | 116 | ); |
| 117 | 117 | } |
| 118 | 118 | } else { |
@@ -136,7 +136,7 @@ discard block |
||
| 136 | 136 | if ($siteHandle !== null) { |
| 137 | 137 | $site = Craft::$app->getSites()->getSiteByHandle($siteHandle); |
| 138 | 138 | if (!$site) { |
| 139 | - throw new NotFoundHttpException('Invalid site handle: ' . $siteHandle); |
|
| 139 | + throw new NotFoundHttpException('Invalid site handle: '.$siteHandle); |
|
| 140 | 140 | } |
| 141 | 141 | $siteId = $site->id; |
| 142 | 142 | } |
@@ -5,7 +5,7 @@ |
||
| 5 | 5 | |
| 6 | 6 | return static function(ECSConfig $ecsConfig): void { |
| 7 | 7 | $ecsConfig->paths([ |
| 8 | - __DIR__ . '/src', |
|
| 8 | + __DIR__.'/src', |
|
| 9 | 9 | __FILE__, |
| 10 | 10 | ]); |
| 11 | 11 | $ecsConfig->parallel(); |