Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PATCH] Add optional language parameter to route_load data producer #1328

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions src/Plugin/GraphQL/DataProducer/Routing/RouteLoad.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@
* consumes = {
* "path" = @ContextDefinition("string",
* label = @Translation("Path")
* ),
* "language" = @ContextDefinition("string",
* label = @Translation("Language"),
* required = FALSE
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should specify a default value und here, which is Language::LANGCODE_NOT_SPECIFIED

* )
* }
* )
Expand Down Expand Up @@ -90,12 +94,13 @@ public function __construct(
* Resolver.
*
* @param string $path
* @param string $language
* @param \Drupal\Core\Cache\RefinableCacheableDependencyInterface $metadata
*
* @return \Drupal\Core\Url|null
*/
public function resolve($path, RefinableCacheableDependencyInterface $metadata) {
$redirect = $this->redirectRepository ? $this->redirectRepository->findMatchingRedirect($path, []) : NULL;
public function resolve($path, $language, RefinableCacheableDependencyInterface $metadata) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should use type hints for all new parameters, in this case string.

$redirect = $this->redirectRepository ? $this->redirectRepository->findMatchingRedirect($path, [], $language) : NULL;
if ($redirect !== NULL) {
$url = $redirect->getRedirectUrl();
}
Expand Down