示例#1
0
文件: Jrd.php 项目: k42b3/psx-ws
 protected function buildLink(Link $link)
 {
     $row = array('rel' => $link->getRel());
     $type = $link->getType();
     if (!empty($type)) {
         $row['type'] = $type;
     }
     $href = $link->getHref();
     if (!empty($href)) {
         $row['href'] = $href;
     }
     $template = $link->getTemplate();
     if (!empty($template)) {
         $row['template'] = $template;
     }
     $titles = $link->getTitles();
     if (!empty($titles)) {
         $row['titles'] = $titles;
     }
     $properties = $link->getProperties();
     if (!empty($properties)) {
         $row['properties'] = $properties;
     }
     return $row;
 }
示例#2
0
文件: Xrd.php 项目: k42b3/psx-ws
 protected function buildLink(XMLWriter $writer, Link $link)
 {
     $writer->startElement('Link');
     $writer->writeAttribute('rel', $link->getRel());
     $type = $link->getType();
     if (!empty($type)) {
         $writer->writeAttribute('type', $type);
     }
     $href = $link->getHref();
     $template = $link->getTemplate();
     if (!empty($href)) {
         $writer->writeAttribute('href', $href);
     } else {
         if (!empty($template)) {
             $writer->writeAttribute('template', $template);
         }
     }
     $titles = $link->getTitles();
     if (!empty($titles)) {
         foreach ($titles as $lang => $title) {
             if ($lang == 'default') {
                 $writer->writeElement('Title', $title);
             } else {
                 $writer->startElement('Title');
                 $writer->writeAttribute('xml:lang', $lang);
                 $writer->text($title);
                 $writer->endElement();
             }
         }
     }
     $properties = $link->getProperties();
     if (!empty($properties)) {
         foreach ($properties as $type => $value) {
             if ($value === null) {
                 $writer->startElement('Property');
                 $writer->writeAttribute('type', $type);
                 $writer->writeAttribute('xsi:nil', 'true');
                 $writer->endElement();
             } else {
                 $writer->startElement('Property');
                 $writer->writeAttribute('type', $type);
                 $writer->text($value);
                 $writer->endElement();
             }
         }
     }
     $writer->endElement();
 }