Exemplo n.º 1
0
function loadRegisterXml($filename)
{
    $xml = file_get_contents($filename);
    $resourceNode = @simplexml_load_string($xml);
    if (!$resourceNode) {
        throw new RuntimeException("Failed to parse " . $filename);
    }
    $resource = new Resource();
    $resource->setType('perinatologie/dossier');
    foreach ($resourceNode->property as $propertyNode) {
        $property = new Property((string) $propertyNode['name'], (string) $propertyNode);
        $resource->addProperty($property);
    }
    foreach ($resourceNode->share as $shareNode) {
        $share = new Share();
        $share->setName((string) $shareNode->name);
        $share->setIdentifierType((string) $shareNode->identifier['type']);
        $share->setIdentifier((string) $shareNode->identifier);
        $share->setPermission((string) $shareNode->permission);
        $resource->addShare($share);
    }
    return $resource;
}