private function XmlFileLoader::getArgumentsAsPhp in Service Container 7.2
Same name and namespace in other branches
- 7 modules/providers/service_container_symfony/lib/Symfony/Component/DependencyInjection/Loader/XmlFileLoader.php \Symfony\Component\DependencyInjection\Loader\XmlFileLoader::getArgumentsAsPhp()
Returns arguments as valid php types.
Parameters
\DOMElement $node:
string $name:
bool $lowercase:
Return value
mixed
2 calls to XmlFileLoader::getArgumentsAsPhp()
- XmlFileLoader::parseDefinition in modules/
providers/ service_container_symfony/ lib/ Symfony/ Component/ DependencyInjection/ Loader/ XmlFileLoader.php - Parses an individual Definition.
- XmlFileLoader::parseParameters in modules/
providers/ service_container_symfony/ lib/ Symfony/ Component/ DependencyInjection/ Loader/ XmlFileLoader.php - Parses parameters.
File
- modules/
providers/ service_container_symfony/ lib/ Symfony/ Component/ DependencyInjection/ Loader/ XmlFileLoader.php, line 341
Class
- XmlFileLoader
- XmlFileLoader loads XML files service definitions.
Namespace
Symfony\Component\DependencyInjection\LoaderCode
private function getArgumentsAsPhp(\DOMElement $node, $name, $lowercase = true) {
$arguments = array();
foreach ($this
->getChildren($node, $name) as $arg) {
if ($arg
->hasAttribute('name')) {
$arg
->setAttribute('key', $arg
->getAttribute('name'));
}
if (!$arg
->hasAttribute('key')) {
$key = !$arguments ? 0 : max(array_keys($arguments)) + 1;
}
else {
$key = $arg
->getAttribute('key');
}
// parameter keys are case insensitive
if ('parameter' == $name && $lowercase) {
$key = strtolower($key);
}
// this is used by DefinitionDecorator to overwrite a specific
// argument of the parent definition
if ($arg
->hasAttribute('index')) {
$key = 'index_' . $arg
->getAttribute('index');
}
switch ($arg
->getAttribute('type')) {
case 'service':
$onInvalid = $arg
->getAttribute('on-invalid');
$invalidBehavior = ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE;
if ('ignore' == $onInvalid) {
$invalidBehavior = ContainerInterface::IGNORE_ON_INVALID_REFERENCE;
}
elseif ('null' == $onInvalid) {
$invalidBehavior = ContainerInterface::NULL_ON_INVALID_REFERENCE;
}
if ($strict = $arg
->getAttribute('strict')) {
$strict = XmlUtils::phpize($strict);
}
else {
$strict = true;
}
$arguments[$key] = new Reference($arg
->getAttribute('id'), $invalidBehavior, $strict);
break;
case 'expression':
$arguments[$key] = new Expression($arg->nodeValue);
break;
case 'collection':
$arguments[$key] = $this
->getArgumentsAsPhp($arg, $name, false);
break;
case 'string':
$arguments[$key] = $arg->nodeValue;
break;
case 'constant':
$arguments[$key] = constant($arg->nodeValue);
break;
default:
$arguments[$key] = XmlUtils::phpize($arg->nodeValue);
}
}
return $arguments;
}