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

Breadcrumb

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

function InputBag::get

Returns a scalar input value by name.

Parameters

string|int|float|bool|null $default The default value if the input key does not exist:

Overrides ParameterBag::get

1 call to InputBag::get()
InputBag::getString in vendor/symfony/http-foundation/InputBag.php
Returns the parameter value converted to string.

File

vendor/symfony/http-foundation/InputBag.php, line 29

Class

InputBag
InputBag is a container for user input values such as $_GET, $_POST, $_REQUEST, and $_COOKIE.

Namespace

Symfony\Component\HttpFoundation

Code

public function get(string $key, mixed $default = null) : string|int|float|bool|null {
    if (null !== $default && !\is_scalar($default) && !$default instanceof \Stringable) {
        throw new \InvalidArgumentException(\sprintf('Expected a scalar value as a 2nd argument to "%s()", "%s" given.', __METHOD__, get_debug_type($default)));
    }
    $value = parent::get($key, $this);
    if (null !== $value && $this !== $value && !\is_scalar($value) && !$value instanceof \Stringable) {
        throw new BadRequestException(\sprintf('Input value "%s" contains a non-scalar value.', $key));
    }
    return $this === $value ? $default : $value;
}

API Navigation

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