/** * Render a representation of a ResourceLinks object. * * @param ResourceLinks $resource A resource links object. * * @return A representation of the object. */ public function renderResourceLinks(ResourceLinks $resource) { $xml = ''; foreach ($resource->getLinks() as $rel => $link) { if (is_array($link)) { foreach ($link as $eachLink) { $xml .= $this->renderLink($rel, $eachLink); } } else { $xml .= $this->renderLink($rel, $link); } } return $xml; }
/** * Render a representation of a ResourceLinks object. * * @param ResourceLinks $resource A resource links object. * * @return A representation of the object. */ public function renderResourceLinks(ResourceLinks $resource) { $data = array(); foreach ($resource->getLinks() as $rel => $link) { if (is_array($link)) { foreach ($link as $eachLink) { $data[$rel][] = $this->render($eachLink); } } else { $data[$rel] = $this->render($link); } } return $data; }