@@ -251,7 +251,7 @@ discard block |
||
| 251 | 251 | if ($redirectConfig === null) { |
| 252 | 252 | throw new NotFoundHttpException('Redirect not found'); |
| 253 | 253 | } |
| 254 | - $redirectConfig['id'] = (int)$redirectConfig['id']; |
|
| 254 | + $redirectConfig['id'] = (int) $redirectConfig['id']; |
|
| 255 | 255 | // Handle enforcing trailing slashes |
| 256 | 256 | $generalConfig = Craft::$app->getConfig()->getGeneral(); |
| 257 | 257 | if ($generalConfig->addTrailingSlashesToUrls && $redirectConfig['redirectMatchType'] === 'exactmatch') { |
@@ -314,13 +314,13 @@ discard block |
||
| 314 | 314 | if (!preg_match('/\.[^\/]+$/', $url) && strpos($url, '?') === false) { |
| 315 | 315 | // If it's a root relative URL, assume it's a site URL |
| 316 | 316 | if (UrlHelper::isRootRelativeUrl($url)) { |
| 317 | - return rtrim($url, '/') . '/'; |
|
| 317 | + return rtrim($url, '/').'/'; |
|
| 318 | 318 | } |
| 319 | 319 | // If the URL matches any of the site's base URLs, assume it's a site URL |
| 320 | 320 | $sites = Craft::$app->getSites()->getAllSites(); |
| 321 | 321 | foreach ($sites as $site) { |
| 322 | 322 | if (strpos($url, $site->getBaseUrl()) === 0) { |
| 323 | - return rtrim($url, '/') . '/'; |
|
| 323 | + return rtrim($url, '/').'/'; |
|
| 324 | 324 | } |
| 325 | 325 | } |
| 326 | 326 | } |
@@ -299,7 +299,7 @@ discard block |
||
| 299 | 299 | { |
| 300 | 300 | $csv->setOffset(1); |
| 301 | 301 | $columns = ArrayHelper::filterEmptyStringsFromArray($columns); |
| 302 | - $csv->each(function ($row) use ($headers, $columns) { |
|
| 302 | + $csv->each(function($row) use ($headers, $columns) { |
|
| 303 | 303 | $redirectConfig = [ |
| 304 | 304 | 'id' => 0, |
| 305 | 305 | ]; |
@@ -312,7 +312,7 @@ discard block |
||
| 312 | 312 | } |
| 313 | 313 | $index++; |
| 314 | 314 | } |
| 315 | - Craft::debug('Importing row: ' . print_r($redirectConfig, true), __METHOD__); |
|
| 315 | + Craft::debug('Importing row: '.print_r($redirectConfig, true), __METHOD__); |
|
| 316 | 316 | Retour::$plugin->redirects->saveRedirect($redirectConfig); |
| 317 | 317 | |
| 318 | 318 | return true; |
@@ -345,7 +345,7 @@ discard block |
||
| 345 | 345 | } |
| 346 | 346 | $index++; |
| 347 | 347 | } |
| 348 | - Craft::debug('Importing row: ' . print_r($redirectConfig, true), __METHOD__); |
|
| 348 | + Craft::debug('Importing row: '.print_r($redirectConfig, true), __METHOD__); |
|
| 349 | 349 | Retour::$plugin->redirects->saveRedirect($redirectConfig); |
| 350 | 350 | } |
| 351 | 351 | } |
@@ -41,17 +41,17 @@ |
||
| 41 | 41 | $retourType = GqlEntityRegistry::getEntity($typeName) |
| 42 | 42 | ?: GqlEntityRegistry::createEntity($typeName, new RetourType([ |
| 43 | 43 | 'name' => $typeName, |
| 44 | - 'args' => function () use ($retourArgs) { |
|
| 44 | + 'args' => function() use ($retourArgs) { |
|
| 45 | 45 | return $retourArgs; |
| 46 | 46 | }, |
| 47 | - 'fields' => function () use ($retourFields) { |
|
| 47 | + 'fields' => function() use ($retourFields) { |
|
| 48 | 48 | return $retourFields; |
| 49 | 49 | }, |
| 50 | 50 | 'description' => 'This entity has all the Retour fields', |
| 51 | 51 | ])); |
| 52 | 52 | |
| 53 | 53 | $gqlTypes[$typeName] = $retourType; |
| 54 | - TypeLoader::registerType($typeName, function () use ($retourType) { |
|
| 54 | + TypeLoader::registerType($typeName, function() use ($retourType) { |
|
| 55 | 55 | return $retourType; |
| 56 | 56 | }); |
| 57 | 57 | |
@@ -50,7 +50,7 @@ |
||
| 50 | 50 | 'name' => static::getName(), |
| 51 | 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 | ])); |
@@ -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 | ]; |
@@ -64,8 +64,8 @@ |
||
| 64 | 64 | if ($redirect === null && Craft::$app->getElements()->getElementByUri(trim($uri, '/'), $siteId) === null) { |
| 65 | 65 | // Set the `site` virtual field |
| 66 | 66 | $redirect['site'] = null; |
| 67 | - if (isset($redirect['siteId']) && (int)$redirect['siteId'] !== 0) { |
|
| 68 | - $site = Craft::$app->getSites()->getSiteById((int)$redirect['siteId']); |
|
| 67 | + if (isset($redirect['siteId']) && (int) $redirect['siteId'] !== 0) { |
|
| 68 | + $site = Craft::$app->getSites()->getSiteById((int) $redirect['siteId']); |
|
| 69 | 69 | if ($site !== null) { |
| 70 | 70 | $redirect['site'] = $site->handle; |
| 71 | 71 | } |
@@ -62,36 +62,36 @@ |
||
| 62 | 62 | // Boolean field |
| 63 | 63 | $retourField |
| 64 | 64 | ->addBooleanField($field) |
| 65 | - ->resolve(function ($redirect) use ($field) { |
|
| 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 |
| 71 | 71 | $retourField |
| 72 | 72 | ->addIntField($field) |
| 73 | - ->resolve(function ($redirect) use ($field) { |
|
| 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 |
| 79 | 79 | $retourField |
| 80 | 80 | ->addStringField($field) |
| 81 | - ->resolve(function ($redirect) use ($field) { |
|
| 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 | } |
| 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 */ |
@@ -309,7 +309,7 @@ discard block |
||
| 309 | 309 | Event::on( |
| 310 | 310 | ClearCaches::class, |
| 311 | 311 | ClearCaches::EVENT_REGISTER_CACHE_OPTIONS, |
| 312 | - function (RegisterCacheOptionsEvent $event) { |
|
| 312 | + function(RegisterCacheOptionsEvent $event) { |
|
| 313 | 313 | Craft::debug( |
| 314 | 314 | 'ClearCaches::EVENT_REGISTER_CACHE_OPTIONS', |
| 315 | 315 | __METHOD__ |
@@ -325,7 +325,7 @@ discard block |
||
| 325 | 325 | Event::on( |
| 326 | 326 | Plugins::class, |
| 327 | 327 | Plugins::EVENT_AFTER_INSTALL_PLUGIN, |
| 328 | - function (PluginEvent $event) { |
|
| 328 | + function(PluginEvent $event) { |
|
| 329 | 329 | if ($event->plugin === $this) { |
| 330 | 330 | // Invalidate our caches after we've been installed |
| 331 | 331 | $this->clearAllCaches(); |
@@ -352,7 +352,7 @@ discard block |
||
| 352 | 352 | Event::on( |
| 353 | 353 | CraftVariable::class, |
| 354 | 354 | CraftVariable::EVENT_INIT, |
| 355 | - function (Event $event) { |
|
| 355 | + function(Event $event) { |
|
| 356 | 356 | /** @var CraftVariable $variable */ |
| 357 | 357 | $variable = $event->sender; |
| 358 | 358 | $variable->set('retour', [ |
@@ -365,7 +365,7 @@ discard block |
||
| 365 | 365 | Event::on( |
| 366 | 366 | Elements::class, |
| 367 | 367 | Elements::EVENT_BEFORE_SAVE_ELEMENT, |
| 368 | - function (ElementEvent $event) { |
|
| 368 | + function(ElementEvent $event) { |
|
| 369 | 369 | Craft::debug( |
| 370 | 370 | 'Elements::EVENT_BEFORE_SAVE_ELEMENT', |
| 371 | 371 | __METHOD__ |
@@ -396,7 +396,7 @@ discard block |
||
| 396 | 396 | Event::on( |
| 397 | 397 | Elements::class, |
| 398 | 398 | Elements::EVENT_AFTER_SAVE_ELEMENT, |
| 399 | - function (ElementEvent $event) { |
|
| 399 | + function(ElementEvent $event) { |
|
| 400 | 400 | Craft::debug( |
| 401 | 401 | 'Elements::EVENT_AFTER_SAVE_ELEMENT', |
| 402 | 402 | __METHOD__ |
@@ -418,7 +418,7 @@ discard block |
||
| 418 | 418 | Event::on( |
| 419 | 419 | Plugins::class, |
| 420 | 420 | Plugins::EVENT_AFTER_LOAD_PLUGINS, |
| 421 | - function () { |
|
| 421 | + function() { |
|
| 422 | 422 | // Install these only after all other plugins have loaded |
| 423 | 423 | $request = Craft::$app->getRequest(); |
| 424 | 424 | // Only respond to non-console site requests |
@@ -435,7 +435,7 @@ discard block |
||
| 435 | 435 | Event::on( |
| 436 | 436 | Fields::class, |
| 437 | 437 | Fields::EVENT_REGISTER_FIELD_TYPES, |
| 438 | - function (RegisterComponentTypesEvent $event) { |
|
| 438 | + function(RegisterComponentTypesEvent $event) { |
|
| 439 | 439 | $event->types[] = ShortLinkField::class; |
| 440 | 440 | } |
| 441 | 441 | ); |
@@ -444,7 +444,7 @@ discard block |
||
| 444 | 444 | Event::on( |
| 445 | 445 | Gql::class, |
| 446 | 446 | Gql::EVENT_REGISTER_GQL_TYPES, |
| 447 | - function (RegisterGqlTypesEvent $event) { |
|
| 447 | + function(RegisterGqlTypesEvent $event) { |
|
| 448 | 448 | Craft::debug( |
| 449 | 449 | 'Gql::EVENT_REGISTER_GQL_TYPES', |
| 450 | 450 | __METHOD__ |
@@ -456,7 +456,7 @@ discard block |
||
| 456 | 456 | Event::on( |
| 457 | 457 | Gql::class, |
| 458 | 458 | Gql::EVENT_REGISTER_GQL_QUERIES, |
| 459 | - function (RegisterGqlQueriesEvent $event) { |
|
| 459 | + function(RegisterGqlQueriesEvent $event) { |
|
| 460 | 460 | Craft::debug( |
| 461 | 461 | 'Gql::EVENT_REGISTER_GQL_QUERIES', |
| 462 | 462 | __METHOD__ |
@@ -472,7 +472,7 @@ discard block |
||
| 472 | 472 | Event::on( |
| 473 | 473 | Gql::class, |
| 474 | 474 | Gql::EVENT_REGISTER_GQL_SCHEMA_COMPONENTS, |
| 475 | - function (RegisterGqlSchemaComponentsEvent $event) { |
|
| 475 | + function(RegisterGqlSchemaComponentsEvent $event) { |
|
| 476 | 476 | Craft::debug( |
| 477 | 477 | 'Gql::EVENT_REGISTER_GQL_SCHEMA_COMPONENTS', |
| 478 | 478 | __METHOD__ |
@@ -502,7 +502,7 @@ discard block |
||
| 502 | 502 | Event::on( |
| 503 | 503 | UrlManager::class, |
| 504 | 504 | UrlManager::EVENT_REGISTER_SITE_URL_RULES, |
| 505 | - function (RegisterUrlRulesEvent $event) { |
|
| 505 | + function(RegisterUrlRulesEvent $event) { |
|
| 506 | 506 | Craft::debug( |
| 507 | 507 | 'UrlManager::EVENT_REGISTER_SITE_URL_RULES', |
| 508 | 508 | __METHOD__ |
@@ -525,7 +525,7 @@ discard block |
||
| 525 | 525 | Event::on( |
| 526 | 526 | Dashboard::class, |
| 527 | 527 | Dashboard::EVENT_REGISTER_WIDGET_TYPES, |
| 528 | - function (RegisterComponentTypesEvent $event) { |
|
| 528 | + function(RegisterComponentTypesEvent $event) { |
|
| 529 | 529 | $event->types[] = RetourWidget::class; |
| 530 | 530 | } |
| 531 | 531 | ); |
@@ -533,7 +533,7 @@ discard block |
||
| 533 | 533 | Event::on( |
| 534 | 534 | UrlManager::class, |
| 535 | 535 | UrlManager::EVENT_REGISTER_CP_URL_RULES, |
| 536 | - function (RegisterUrlRulesEvent $event) { |
|
| 536 | + function(RegisterUrlRulesEvent $event) { |
|
| 537 | 537 | Craft::debug( |
| 538 | 538 | 'UrlManager::EVENT_REGISTER_CP_URL_RULES', |
| 539 | 539 | __METHOD__ |
@@ -549,7 +549,7 @@ discard block |
||
| 549 | 549 | Event::on( |
| 550 | 550 | UserPermissions::class, |
| 551 | 551 | UserPermissions::EVENT_REGISTER_PERMISSIONS, |
| 552 | - function (RegisterUserPermissionsEvent $event) { |
|
| 552 | + function(RegisterUserPermissionsEvent $event) { |
|
| 553 | 553 | Craft::debug( |
| 554 | 554 | 'UserPermissions::EVENT_REGISTER_PERMISSIONS', |
| 555 | 555 | __METHOD__ |
@@ -571,7 +571,7 @@ discard block |
||
| 571 | 571 | Event::on( |
| 572 | 572 | ErrorHandler::class, |
| 573 | 573 | ErrorHandler::EVENT_BEFORE_HANDLE_EXCEPTION, |
| 574 | - function (ExceptionEvent $event) { |
|
| 574 | + function(ExceptionEvent $event) { |
|
| 575 | 575 | Craft::debug( |
| 576 | 576 | 'ErrorHandler::EVENT_BEFORE_HANDLE_EXCEPTION', |
| 577 | 577 | __METHOD__ |
@@ -107,7 +107,7 @@ |
||
| 107 | 107 | } |
| 108 | 108 | } else if (!StringHelper::startsWith($value, 'http')) { |
| 109 | 109 | $siteUrl = $element->getSite()->getBaseUrl(); |
| 110 | - $value = rtrim($siteUrl, '/') . '/' . ltrim($value, '/'); |
|
| 110 | + $value = rtrim($siteUrl, '/').'/'.ltrim($value, '/'); |
|
| 111 | 111 | } |
| 112 | 112 | |
| 113 | 113 | if (!empty($value)) { |