protected function buildAccount(DocumentAbstract $document, Account\Record $account) { // subject $subject = $account->name . '@' . $this->base->getHost(); $document->setSubject($subject); // alias $document->setAliases(array($account->profileUrl)); // id $document->addProperty('http://ns.amun-project.org/2011/meta/id', $account->globalId); $document->addProperty('http://ns.amun-project.org/2011/meta/name', $account->name); $document->addProperty('http://ns.amun-project.org/2011/meta/date', $account->getDate()->format(DateTime::ATOM)); // profile $link = new Link(); $link->setRel('profile'); $link->setType('text/html'); $link->setHref($account->profileUrl); $document->addLink($link); // activity atom feed $href = $this->config['psx_url'] . '/' . $this->config['psx_dispatch'] . 'api/my/activity/' . $account->id . '?format=atom'; $link = new Link(); $link->setRel('alternate'); $link->setType('application/atom+xml'); $link->setHref($href); $document->addLink($link); // json activity streams $href = $this->config['psx_url'] . '/' . $this->config['psx_dispatch'] . 'api/my/activity/' . $account->id . '?format=jas'; $link = new Link(); $link->setRel('alternate'); $link->setType('application/stream+json'); $link->setHref($href); $document->addLink($link); }
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; }