/** * create a new instance according to the instance definition * * @param __ConfigurationSection $instance_definition */ private function &_createInstanceDefinition(__ConfigurationSection $instance_config_section) { if ($instance_config_section->hasAttribute('id')) { $instance_id = $instance_config_section->getAttribute('id'); } else { $instance_id = uniqid(); } $instance_class = $instance_config_section->getAttribute('class'); $instance_definition = new __InstanceDefinition($instance_id); $instance_definition->setClass($instance_class); if ($instance_config_section->hasAttribute('singleton')) { $instance_definition->setSingleton($instance_config_section->getAttribute('singleton')); } if ($instance_config_section->hasAttribute('scope')) { $instance_definition->setScope($instance_config_section->getAttribute('scope')); } if ($instance_config_section->hasAttribute('lazy-init')) { $instance_definition->setLazy(__ConfigurationValueResolver::toBool($instance_config_section->getAttribute('lazy-init'))); } else { if ($instance_config_section->hasAttribute('lazy')) { $instance_definition->setLazy(__ConfigurationValueResolver::toBool($instance_config_section->getAttribute('lazy'))); } } if ($instance_config_section->hasAttribute('startup-method')) { $instance_definition->setStartupMethod($instance_config_section->getAttribute('startup-method')); } if ($instance_config_section->hasAttribute('shutdown-method')) { $instance_definition->setShutdownMethod($instance_config_section->getAttribute('shutdown-method')); } if ($instance_config_section->hasAttribute('factory-method')) { $instance_definition->setFactoryMethod($instance_config_section->getAttribute('factory-method')); } if ($instance_config_section->hasAttribute('factory-instance')) { $instance_definition->setFactoryInstanceId($instance_config_section->getAttribute('factory-instance')); } $properties = $instance_config_section->getSections(); foreach ($properties as &$property) { switch ($property->getName()) { case 'property': $this->_parseProperty($property, $instance_definition); break; case 'constructor-arg': $this->_parseConstructorArgument($property, $instance_definition); break; } } return $instance_definition; }