RouteMatchValueResolver.php

Same filename in other branches
  1. 8.9.x core/lib/Drupal/Core/Controller/ArgumentResolver/RouteMatchValueResolver.php
  2. 10 core/lib/Drupal/Core/Controller/ArgumentResolver/RouteMatchValueResolver.php
  3. 11.x core/lib/Drupal/Core/Controller/ArgumentResolver/RouteMatchValueResolver.php

Namespace

Drupal\Core\Controller\ArgumentResolver

File

core/lib/Drupal/Core/Controller/ArgumentResolver/RouteMatchValueResolver.php

View source
<?php

namespace Drupal\Core\Controller\ArgumentResolver;

use Drupal\Core\Routing\RouteMatch;
use Drupal\Core\Routing\RouteMatchInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpKernel\Controller\ArgumentValueResolverInterface;
use Symfony\Component\HttpKernel\ControllerMetadata\ArgumentMetadata;

/**
 * Yields a RouteMatch object based on the request object passed along.
 */
final class RouteMatchValueResolver implements ArgumentValueResolverInterface {
    
    /**
     * {@inheritdoc}
     */
    public function supports(Request $request, ArgumentMetadata $argument) {
        return $argument->getType() == RouteMatchInterface::class || is_subclass_of($argument->getType(), RouteMatchInterface::class);
    }
    
    /**
     * {@inheritdoc}
     */
    public function resolve(Request $request, ArgumentMetadata $argument) {
        (yield RouteMatch::createFromRequest($request));
    }

}

Classes

Title Deprecated Summary
RouteMatchValueResolver Yields a RouteMatch object based on the request object passed along.

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.