protected function parseLink(array $row) { $link = new Link(); if (isset($row['rel'])) { $link->setRel($row['rel']); } else { throw new Exception('Rel member must be present'); } if (isset($row['type'])) { $link->setType($row['type']); } if (isset($row['href'])) { $link->setHref($row['href']); } else { if (isset($row['template'])) { $link->setTemplate($row['template']); } } if (isset($row['titles'])) { $link->setTitles($row['titles']); } if (isset($row['properties'])) { $link->setProperties($row['properties']); } return $link; }
protected function parseLink(SimpleXMLElement $element) { $link = new Link(); if (isset($element['rel'])) { $link->setRel((string) $element['rel']); } else { throw new Exception('Rel member must be present'); } if (isset($element['type'])) { $link->setType((string) $element['type']); } if (isset($element['href'])) { $link->setHref((string) $element['href']); } else { if (isset($element['template'])) { $link->setTemplate((string) $element['template']); } } if (isset($element->Title)) { $titles = array(); foreach ($element->Title as $title) { $lang = (string) $title->attributes('xml', true)->lang; if (empty($lang)) { $lang = 'default'; } $titles[$lang] = (string) $title; } $link->setTitles($titles); } if (isset($element->Property)) { $properties = array(); foreach ($element->Property as $property) { $type = isset($property['type']) ? (string) $property['type'] : null; if (!empty($type)) { $value = $property->attributes('xsi', true)->nil; if ($value == 'true') { $properties[$type] = null; } else { $properties[$type] = (string) $property; } } } $link->setProperties($properties); } return $link; }