Horde_Feed_Entry_Atom::link PHP Method

    public function link($rel = null)
    {
        if ($rel === null) {
            return parent::__call('link', null);
        }
        // index link tags by their "rel" attribute.
        $links = parent::__get('link');
        if (!is_array($links)) {
            if ($links instanceof Horde_Xml_Element) {
                $links = array($links);
            } else {
                return $links;
            }
        }
        foreach ($links as $link) {
            if (empty($link['rel'])) {
                continue;
            }
            if ($rel == $link['rel']) {
                return $link['href'];
            }
        }
        return null;
    }

Usage Example

Exemplo n.º 1
0
 public function testEdit()
 {
     $mock = new Horde_Http_Request_Mock();
     $mock->setResponse(new Horde_Http_Response_Mock('', fopen(__DIR__ . '/fixtures/AtomPublishingTest-updated-entry.xml', 'r'), array('HTTP/1.1 200')));
     $httpClient = new Horde_Http_Client(array('request' => $mock));
     // The base feed URI is the same as the POST URI, so just supply the
     // Horde_Feed_Entry_Atom object with that.
     $contents = file_get_contents(__DIR__ . '/fixtures/AtomPublishingTest-before-update.xml');
     $entry = new Horde_Feed_Entry_Atom($contents, $httpClient);
     // Initial state.
     $this->assertEquals('2005-05-23T16:26:00-08:00', $entry->updated(), 'Initial state of updated timestamp does not match');
     $this->assertEquals('http://example.com/Feed/1/1/', $entry->link('edit'), 'Initial state of edit link does not match');
     // Just change the entry's properties directly.
     $entry->content = '1.2';
     // Then save the changes.
     $entry->save();
     // New state.
     $this->assertEquals('1.2', $entry->content(), 'Content change did not stick');
     $this->assertEquals('2005-05-23T16:27:00-08:00', $entry->updated(), 'New updated link is not correct');
     $this->assertEquals('http://example.com/Feed/1/2/', $entry->link('edit'), 'New edit link is not correct');
 }
All Usage Examples Of Horde_Feed_Entry_Atom::link
Horde_Feed_Entry_Atom