forked from eschnou/php-atom-lib
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAtomFeedAdapter.php
54 lines (45 loc) · 1.38 KB
/
AtomFeedAdapter.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<?php
require_once 'AtomSourceAdapter.php';
require_once 'AtomEntryAdapter.php';
require_once 'AtomGeneratorAdapter.php';
class AtomFeedAdapter extends AtomSourceAdapter {
protected $_entry;
protected $_generator;
/**
* @return AtomEntryAdapter;
*/
public function addEntry() {
$newEntry = $this->_addElement(AtomNS::NS, AtomNS::ENTRY_ELEMENT);
return $this->_entry[] = new AtomEntryAdapter($newEntry);
}
public function getEntry() {
return $this->_entry;
}
public function getGenerator() {
return $this->_generator;
}
public function setGenerator($value) {
if (!isset($this->_generator)) {
$generator = $this->_addElement(AtomNS::NS, AtomNS::GENERATOR_ELEMENT, $value);
$this->_generator = new AtomGeneratorAdapter($generator);
return;
}
$this->_generator->value = $value;
}
public function __construct($data=null, $data_is_url=false) {
parent::__construct(AtomNS::FEED_ELEMENT, $data, $data_is_url);
//$this->_init();
}
protected function _init() {
parent::_init();
$this->_entry = array();
if (isset($this->_element[AtomNS::ENTRY_ELEMENT])){
foreach ($this->_element[AtomNS::ENTRY_ELEMENT] as $entry) {
$this->_entry[] = new AtomEntryAdapter($entry);
}
}
if (isset($this->_element[AtomNS::GENERATOR_ELEMENT][0])) {
$this->_generator = new AtomGeneratorAdapter($this->_element[AtomNS::GENERATOR_ELEMENT][0]);
}
}
}