You are here

public function RouteLoad::resolve in GraphQL 8.4

Resolver.

Parameters

string $path:

\Drupal\Core\Cache\RefinableCacheableDependencyInterface $metadata:

Return value

\Drupal\Core\Url|null

File

src/Plugin/GraphQL/DataProducer/Routing/RouteLoad.php, line 97

Class

RouteLoad
Returns the URL of the given path.

Namespace

Drupal\graphql\Plugin\GraphQL\DataProducer\Routing

Code

public function resolve($path, RefinableCacheableDependencyInterface $metadata) {
  if ($this->redirectRepository) {

    /** @var \Drupal\redirect\Entity\Redirect|null $redirect */
    $redirect = $this->redirectRepository
      ->findMatchingRedirect($path, []);
    if ($redirect) {
      return $redirect
        ->getRedirectUrl();
    }
  }
  if (($url = $this->pathValidator
    ->getUrlIfValidWithoutAccessCheck($path)) && $url
    ->isRouted() && $url
    ->access()) {
    return $url;
  }
  $metadata
    ->addCacheTags([
    '4xx-response',
  ]);
  return NULL;
}