RouteMatchValueResolver.php 899 B

123456789101112131415161718192021222324252627282930
  1. <?php
  2. namespace Drupal\Core\Controller\ArgumentResolver;
  3. use Drupal\Core\Routing\RouteMatch;
  4. use Drupal\Core\Routing\RouteMatchInterface;
  5. use Symfony\Component\HttpFoundation\Request;
  6. use Symfony\Component\HttpKernel\Controller\ArgumentValueResolverInterface;
  7. use Symfony\Component\HttpKernel\ControllerMetadata\ArgumentMetadata;
  8. /**
  9. * Yields a RouteMatch object based on the request object passed along.
  10. */
  11. final class RouteMatchValueResolver implements ArgumentValueResolverInterface {
  12. /**
  13. * {@inheritdoc}
  14. */
  15. public function supports(Request $request, ArgumentMetadata $argument) {
  16. return $argument->getType() == RouteMatchInterface::class || is_subclass_of($argument->getType(), RouteMatchInterface::class);
  17. }
  18. /**
  19. * {@inheritdoc}
  20. */
  21. public function resolve(Request $request, ArgumentMetadata $argument) {
  22. yield RouteMatch::createFromRequest($request);
  23. }
  24. }