/** * * @param \DOMDocument $doc * @return XmlConfigurationDriver */ private function parseDom(\blaze\persistence\cfg\Configuration $config, \DOMDocument $doc, \blaze\lang\String $name, \blaze\io\File $file = null) { if ($doc->documentElement->localName != 'persistence-configuration') { throw new \blaze\lang\IllegalArgumentException($name . ': The first node has to be of the type "persistence-configuration"'); } if ($doc->documentElement->firstChild->localName != 'persistence-factory') { throw new \blaze\lang\IllegalArgumentException($name . ': The first child node has to be of the type "persistence-factory"'); } foreach ($doc->documentElement->firstChild->childNodes as $child) { switch ($child->localName) { case 'property': if ($child->firstChild instanceof \DOMText) { $config->setProperty($child->getAttribute('name'), $child->firstChild->wholeText); } else { $config->setProperty($child->getAttribute('name'), ''); } break; case 'mapping': if ($file === null) { throw new \blaze\lang\Exception('The mapping-tag can only be used if a file or a base path is given.'); } $config->addRessource(new \blaze\io\File($file->getParent(), $child->getAttribute('ressource'))); break; } } }