1 | <?php |
||
25 | class Formatter |
||
26 | { |
||
27 | |||
28 | /** |
||
29 | * @var StandardAbstract |
||
30 | */ |
||
31 | protected $standard; |
||
32 | |||
33 | /** |
||
34 | * @var LoggerInterface |
||
35 | */ |
||
36 | protected $logger; |
||
37 | |||
38 | /** |
||
39 | * @param StandardAbstract $standard |
||
40 | * @param LoggerInterface $logger |
||
41 | */ |
||
42 | 2 | public function __construct(StandardAbstract $standard, LoggerInterface $logger) |
|
43 | { |
||
44 | 2 | $this->standard = $standard; |
|
45 | 2 | $this->logger = $logger; |
|
46 | 2 | } |
|
47 | |||
48 | /** |
||
49 | * @param \DOMDocument $document |
||
50 | * @param FeedInterface $feed |
||
51 | * @return $this |
||
52 | */ |
||
53 | 2 | public function setHeaders(\DOMDocument $document, FeedInterface $feed) |
|
54 | { |
||
55 | 2 | $rules = $this->standard->getFeedRuleSet(); |
|
56 | 2 | $elements = $this->buildElements($rules, $document, $feed); |
|
57 | 2 | foreach ($elements as $element) { |
|
58 | 2 | $this->standard->getMainElement($document)->appendChild($element); |
|
59 | 2 | } |
|
60 | |||
61 | 2 | return $this; |
|
62 | } |
||
63 | |||
64 | /** |
||
65 | * @param \DOMDocument $document |
||
66 | * @param NodeInterface $node |
||
67 | * @return $this |
||
68 | */ |
||
69 | 2 | public function addItem(\DOMDocument $document, NodeInterface $node) |
|
83 | |||
84 | /** |
||
85 | * @param RuleSet $ruleSet |
||
86 | * @param \DOMDocument $document |
||
87 | * @param NodeInterface $node |
||
88 | * @return array |
||
89 | */ |
||
90 | 2 | public function buildElements(RuleSet $ruleSet, \DOMDocument $document, NodeInterface $node) |
|
100 | |||
101 | /** |
||
102 | * @param RuleSet $ruleSet |
||
103 | * @param NodeInterface $node |
||
104 | * @return array|\ArrayIterator |
||
105 | */ |
||
106 | 2 | public function getAllRules(RuleSet $ruleSet, NodeInterface $node) |
|
116 | |||
117 | /** |
||
118 | * @return \DOMDocument |
||
119 | */ |
||
120 | 2 | public function getEmptyDocument() |
|
124 | |||
125 | /** |
||
126 | * @return \DOMDocument |
||
127 | */ |
||
128 | 2 | public function getDocument() |
|
134 | |||
135 | /** |
||
136 | * @param FeedInterface $feed |
||
137 | * @return string |
||
138 | */ |
||
139 | public function toString(FeedInterface $feed) |
||
145 | |||
146 | /** |
||
147 | * @param FeedInterface $feed |
||
148 | * @return \DomDocument |
||
149 | */ |
||
150 | 2 | public function toDom(FeedInterface $feed) |
|
159 | |||
160 | /** |
||
161 | * @param \DOMDocument $document |
||
162 | * @param FeedInterface $feed |
||
163 | * @return $this |
||
164 | */ |
||
165 | 2 | public function setItems(\DOMDocument $document, FeedInterface $feed) |
|
173 | } |
||
174 |