Skip to content

Commit e6034e9

Browse files
authored
fix(route_load): Specify language data type and default value (#1378)
1 parent 28e9423 commit e6034e9

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/Plugin/GraphQL/DataProducer/Routing/RouteLoad.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace Drupal\graphql\Plugin\GraphQL\DataProducer\Routing;
44

55
use Drupal\Core\Cache\RefinableCacheableDependencyInterface;
6+
use Drupal\Core\Language\Language;
67
use Drupal\Core\Path\PathValidatorInterface;
78
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
89
use Drupal\graphql\Plugin\GraphQL\DataProducer\DataProducerPluginBase;
@@ -27,7 +28,8 @@
2728
* ),
2829
* "language" = @ContextDefinition("string",
2930
* label = @Translation("Language"),
30-
* required = FALSE
31+
* required = FALSE,
32+
* default_value = "und"
3133
* )
3234
* }
3335
* )
@@ -94,12 +96,13 @@ public function __construct(
9496
* Resolver.
9597
*
9698
* @param string $path
97-
* @param string $language
99+
* @param string|null $language
98100
* @param \Drupal\Core\Cache\RefinableCacheableDependencyInterface $metadata
99101
*
100102
* @return \Drupal\Core\Url|null
101103
*/
102-
public function resolve($path, $language, RefinableCacheableDependencyInterface $metadata) {
104+
public function resolve($path, ?string $language, RefinableCacheableDependencyInterface $metadata) {
105+
$language = $language ?? Language::LANGCODE_NOT_SPECIFIED;
103106
$redirect = $this->redirectRepository ? $this->redirectRepository->findMatchingRedirect($path, [], $language) : NULL;
104107
if ($redirect !== NULL) {
105108
$url = $redirect->getRedirectUrl();

0 commit comments

Comments
 (0)