You are here

public function ParameterBag::get in Service Container 7.2

Same name and namespace in other branches
  1. 7 modules/providers/service_container_symfony/lib/Symfony/Component/DependencyInjection/ParameterBag/ParameterBag.php \Symfony\Component\DependencyInjection\ParameterBag\ParameterBag::get()

Gets a service container parameter.

@api

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 modules/providers/service_container_symfony/lib/Symfony/Component/DependencyInjection/ParameterBag/ParameterBag.php
Resolves parameters inside a string.

File

modules/providers/service_container_symfony/lib/Symfony/Component/DependencyInjection/ParameterBag/ParameterBag.php, line 89

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];
}