function addPortToDevice($portNode, $uniPortType, $deviceId, $deviceName, $netNode, $domainName) { $deviceNodes = $this->xpath->query(".//x:Node", $netNode); if ($deviceNodes) { foreach ($deviceNodes as $deviceNode) { if ($deviceId == $deviceNode->getAttribute('id')) { $relationNodes = $this->xpath->query(".//x:Relation", $deviceNode); if ($relationNodes) { foreach ($relationNodes as $relationNode) { if ($relationNode->getAttribute("type") == $uniPortType) { $relationNode->appendChild($portNode->cloneNode()); return; } } } return; } } } $deviceNode = $netNode->appendChild($this->xml->createElementNS('http://schemas.ogf.org/nml/2013/05/base#', 'Node')); $deviceNode->setAttribute("id", $deviceId); $name = $deviceNode->appendChild($this->xml->createElementNS('http://schemas.ogf.org/nml/2013/05/base#', 'name')); $name->appendChild($this->xml->createTextNode($deviceName)); $relation = $deviceNode->appendChild($this->xml->createElementNS('http://schemas.ogf.org/nml/2013/05/base#', 'Relation')); $relation->setAttribute("type", "http://schemas.ogf.org/nml/2013/05/base#hasInboundPort"); $relation = $deviceNode->appendChild($this->xml->createElementNS('http://schemas.ogf.org/nml/2013/05/base#', 'Relation')); $relation->setAttribute("type", "http://schemas.ogf.org/nml/2013/05/base#hasOutboundPort"); $location = Device::findLocation($domainName, $deviceName); if ($location) { $locationNode = $deviceNode->appendChild($this->xml->createElement('location')); $lat = $locationNode->appendChild($this->xml->createElement('latitude')); $lat->appendChild($this->xml->createTextNode($location['lat'])); $lng = $locationNode->appendChild($this->xml->createElement('longitude')); $lng->appendChild($this->xml->createTextNode($location['lng'])); $address = $locationNode->appendChild($this->xml->createElement('address')); $address->appendChild($this->xml->createTextNode(urlencode($location['address']))); } $relationNodes = $this->xpath->query(".//x:Relation", $deviceNode); if ($relationNodes) { foreach ($relationNodes as $relationNode) { if ($relationNode->getAttribute("type") == $uniPortType) { $relationNode->appendChild($portNode->cloneNode()); return; } } } }