Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. DefaultValueResolver.php

function DefaultValueResolver::resolve

Overrides ValueResolverInterface::resolve

File

vendor/symfony/http-kernel/Controller/ArgumentResolver/DefaultValueResolver.php, line 25

Class

DefaultValueResolver
Yields the default value defined in the action signature when no value has been given.

Namespace

Symfony\Component\HttpKernel\Controller\ArgumentResolver

Code

public function resolve(Request $request, ArgumentMetadata $argument) : array {
    if ($argument->hasDefaultValue()) {
        return [
            $argument->getDefaultValue(),
        ];
    }
    if (null !== $argument->getType() && $argument->isNullable() && !$argument->isVariadic()) {
        return [
            null,
        ];
    }
    return [];
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal