Esempio n. 1
0
 /**
  * Returns arguments as valid php types.
  *
  * @param \DOMElement $node
  * @param string      $name
  * @param bool        $lowercase
  *
  * @return mixed
  */
 private function getArgumentsAsPhp(\DOMElement $node, $name, $lowercase = true)
 {
     $arguments = [];
     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':
                 $arguments[$key] = $this->containerConfiguration->createReferenceFor($arg->getAttribute('id'), $arg->getAttribute('container') ?: null);
                 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;
 }
 /**
  * @param string $containerName
  * @param string $containerId
  */
 public function addContainer($containerName, $containerId)
 {
     $this->containerConfiguration->addContainer($containerName, $containerId);
 }