You are here

public function ParameterBag::get in Zircon Profile 8

Same name in this branch
  1. 8 vendor/symfony/http-foundation/ParameterBag.php \Symfony\Component\HttpFoundation\ParameterBag::get()
  2. 8 vendor/symfony/dependency-injection/ParameterBag/ParameterBag.php \Symfony\Component\DependencyInjection\ParameterBag\ParameterBag::get()
Same name and namespace in other branches
  1. 8.0 vendor/symfony/dependency-injection/ParameterBag/ParameterBag.php \Symfony\Component\DependencyInjection\ParameterBag\ParameterBag::get()

Gets a service container parameter.

Parameters

string $name The parameter name:

Return value

mixed The parameter value

Throws

ParameterNotFoundException if the parameter is not defined

Overrides ParameterBagInterface::get

1 call to ParameterBag::get()
ParameterBag::resolveString in vendor/symfony/dependency-injection/ParameterBag/ParameterBag.php
Resolves parameters inside a string.

File

vendor/symfony/dependency-injection/ParameterBag/ParameterBag.php, line 77

Class

ParameterBag
Holds parameters.

Namespace

Symfony\Component\DependencyInjection\ParameterBag

Code

public function get($name) {
  $name = strtolower($name);
  if (!array_key_exists($name, $this->parameters)) {
    if (!$name) {
      throw new ParameterNotFoundException($name);
    }
    $alternatives = array();
    foreach ($this->parameters as $key => $parameterValue) {
      $lev = levenshtein($name, $key);
      if ($lev <= strlen($name) / 3 || false !== strpos($key, $name)) {
        $alternatives[] = $key;
      }
    }
    throw new ParameterNotFoundException($name, null, null, null, $alternatives);
  }
  return $this->parameters[$name];
}