comparison vendor/zendframework/zend-feed/src/Writer/Renderer/Feed/AbstractAtom.php @ 2:5311817fb629

Theme updates
author Chris Cannam
date Tue, 10 Jul 2018 13:19:18 +0000
parents c75dbcec494b
children
comparison
equal deleted inserted replaced
1:0b0e5f3b1e83 2:5311817fb629
35 * 35 *
36 * @param DOMDocument $dom 36 * @param DOMDocument $dom
37 * @param DOMElement $root 37 * @param DOMElement $root
38 * @return void 38 * @return void
39 */ 39 */
40 // @codingStandardsIgnoreStart
40 protected function _setLanguage(DOMDocument $dom, DOMElement $root) 41 protected function _setLanguage(DOMDocument $dom, DOMElement $root)
41 { 42 {
43 // @codingStandardsIgnoreEnd
42 if ($this->getDataContainer()->getLanguage()) { 44 if ($this->getDataContainer()->getLanguage()) {
43 $root->setAttribute('xml:lang', $this->getDataContainer() 45 $root->setAttribute('xml:lang', $this->getDataContainer()
44 ->getLanguage()); 46 ->getLanguage());
45 } 47 }
46 } 48 }
51 * @param DOMDocument $dom 53 * @param DOMDocument $dom
52 * @param DOMElement $root 54 * @param DOMElement $root
53 * @return void 55 * @return void
54 * @throws Writer\Exception\InvalidArgumentException 56 * @throws Writer\Exception\InvalidArgumentException
55 */ 57 */
58 // @codingStandardsIgnoreStart
56 protected function _setTitle(DOMDocument $dom, DOMElement $root) 59 protected function _setTitle(DOMDocument $dom, DOMElement $root)
57 { 60 {
58 if (!$this->getDataContainer()->getTitle()) { 61 // @codingStandardsIgnoreEnd
62 if (! $this->getDataContainer()->getTitle()) {
59 $message = 'Atom 1.0 feed elements MUST contain exactly one' 63 $message = 'Atom 1.0 feed elements MUST contain exactly one'
60 . ' atom:title element but a title has not been set'; 64 . ' atom:title element but a title has not been set';
61 $exception = new Writer\Exception\InvalidArgumentException($message); 65 $exception = new Writer\Exception\InvalidArgumentException($message);
62 if (!$this->ignoreExceptions) { 66 if (! $this->ignoreExceptions) {
63 throw $exception; 67 throw $exception;
64 } else { 68 } else {
65 $this->exceptions[] = $exception; 69 $this->exceptions[] = $exception;
66 return; 70 return;
67 } 71 }
79 * 83 *
80 * @param DOMDocument $dom 84 * @param DOMDocument $dom
81 * @param DOMElement $root 85 * @param DOMElement $root
82 * @return void 86 * @return void
83 */ 87 */
88 // @codingStandardsIgnoreStart
84 protected function _setDescription(DOMDocument $dom, DOMElement $root) 89 protected function _setDescription(DOMDocument $dom, DOMElement $root)
85 { 90 {
86 if (!$this->getDataContainer()->getDescription()) { 91 // @codingStandardsIgnoreEnd
92 if (! $this->getDataContainer()->getDescription()) {
87 return; 93 return;
88 } 94 }
89 $subtitle = $dom->createElement('subtitle'); 95 $subtitle = $dom->createElement('subtitle');
90 $root->appendChild($subtitle); 96 $root->appendChild($subtitle);
91 $subtitle->setAttribute('type', 'text'); 97 $subtitle->setAttribute('type', 'text');
99 * @param DOMDocument $dom 105 * @param DOMDocument $dom
100 * @param DOMElement $root 106 * @param DOMElement $root
101 * @return void 107 * @return void
102 * @throws Writer\Exception\InvalidArgumentException 108 * @throws Writer\Exception\InvalidArgumentException
103 */ 109 */
110 // @codingStandardsIgnoreStart
104 protected function _setDateModified(DOMDocument $dom, DOMElement $root) 111 protected function _setDateModified(DOMDocument $dom, DOMElement $root)
105 { 112 {
106 if (!$this->getDataContainer()->getDateModified()) { 113 // @codingStandardsIgnoreEnd
114 if (! $this->getDataContainer()->getDateModified()) {
107 $message = 'Atom 1.0 feed elements MUST contain exactly one' 115 $message = 'Atom 1.0 feed elements MUST contain exactly one'
108 . ' atom:updated element but a modification date has not been set'; 116 . ' atom:updated element but a modification date has not been set';
109 $exception = new Writer\Exception\InvalidArgumentException($message); 117 $exception = new Writer\Exception\InvalidArgumentException($message);
110 if (!$this->ignoreExceptions) { 118 if (! $this->ignoreExceptions) {
111 throw $exception; 119 throw $exception;
112 } else { 120 } else {
113 $this->exceptions[] = $exception; 121 $this->exceptions[] = $exception;
114 return; 122 return;
115 } 123 }
128 * 136 *
129 * @param DOMDocument $dom 137 * @param DOMDocument $dom
130 * @param DOMElement $root 138 * @param DOMElement $root
131 * @return void 139 * @return void
132 */ 140 */
141 // @codingStandardsIgnoreStart
133 protected function _setGenerator(DOMDocument $dom, DOMElement $root) 142 protected function _setGenerator(DOMDocument $dom, DOMElement $root)
134 { 143 {
135 if (!$this->getDataContainer()->getGenerator()) { 144 // @codingStandardsIgnoreEnd
136 $this->getDataContainer()->setGenerator('Zend_Feed_Writer', 145 if (! $this->getDataContainer()->getGenerator()) {
137 Version::VERSION, 'http://framework.zend.com'); 146 $this->getDataContainer()->setGenerator(
147 'Zend_Feed_Writer',
148 Version::VERSION,
149 'http://framework.zend.com'
150 );
138 } 151 }
139 152
140 $gdata = $this->getDataContainer()->getGenerator(); 153 $gdata = $this->getDataContainer()->getGenerator();
141 $generator = $dom->createElement('generator'); 154 $generator = $dom->createElement('generator');
142 $root->appendChild($generator); 155 $root->appendChild($generator);
155 * 168 *
156 * @param DOMDocument $dom 169 * @param DOMDocument $dom
157 * @param DOMElement $root 170 * @param DOMElement $root
158 * @return void 171 * @return void
159 */ 172 */
173 // @codingStandardsIgnoreStart
160 protected function _setLink(DOMDocument $dom, DOMElement $root) 174 protected function _setLink(DOMDocument $dom, DOMElement $root)
161 { 175 {
162 if (!$this->getDataContainer()->getLink()) { 176 // @codingStandardsIgnoreEnd
177 if (! $this->getDataContainer()->getLink()) {
163 return; 178 return;
164 } 179 }
165 $link = $dom->createElement('link'); 180 $link = $dom->createElement('link');
166 $root->appendChild($link); 181 $root->appendChild($link);
167 $link->setAttribute('rel', 'alternate'); 182 $link->setAttribute('rel', 'alternate');
175 * @param DOMDocument $dom 190 * @param DOMDocument $dom
176 * @param DOMElement $root 191 * @param DOMElement $root
177 * @return void 192 * @return void
178 * @throws Writer\Exception\InvalidArgumentException 193 * @throws Writer\Exception\InvalidArgumentException
179 */ 194 */
195 // @codingStandardsIgnoreStart
180 protected function _setFeedLinks(DOMDocument $dom, DOMElement $root) 196 protected function _setFeedLinks(DOMDocument $dom, DOMElement $root)
181 { 197 {
198 // @codingStandardsIgnoreEnd
182 $flinks = $this->getDataContainer()->getFeedLinks(); 199 $flinks = $this->getDataContainer()->getFeedLinks();
183 if (!$flinks || !array_key_exists('atom', $flinks)) { 200 if (! $flinks || ! array_key_exists('atom', $flinks)) {
184 $message = 'Atom 1.0 feed elements SHOULD contain one atom:link ' 201 $message = 'Atom 1.0 feed elements SHOULD contain one atom:link '
185 . 'element with a rel attribute value of "self". This is the ' 202 . 'element with a rel attribute value of "self". This is the '
186 . 'preferred URI for retrieving Atom Feed Documents representing ' 203 . 'preferred URI for retrieving Atom Feed Documents representing '
187 . 'this Atom feed but a feed link has not been set'; 204 . 'this Atom feed but a feed link has not been set';
188 $exception = new Writer\Exception\InvalidArgumentException($message); 205 $exception = new Writer\Exception\InvalidArgumentException($message);
189 if (!$this->ignoreExceptions) { 206 if (! $this->ignoreExceptions) {
190 throw $exception; 207 throw $exception;
191 } else { 208 } else {
192 $this->exceptions[] = $exception; 209 $this->exceptions[] = $exception;
193 return; 210 return;
194 } 211 }
209 * 226 *
210 * @param DOMDocument $dom 227 * @param DOMDocument $dom
211 * @param DOMElement $root 228 * @param DOMElement $root
212 * @return void 229 * @return void
213 */ 230 */
231 // @codingStandardsIgnoreStart
214 protected function _setAuthors(DOMDocument $dom, DOMElement $root) 232 protected function _setAuthors(DOMDocument $dom, DOMElement $root)
215 { 233 {
234 // @codingStandardsIgnoreEnd
216 $authors = $this->container->getAuthors(); 235 $authors = $this->container->getAuthors();
217 if (!$authors || empty($authors)) { 236 if (! $authors || empty($authors)) {
218 /** 237 /**
219 * Technically we should defer an exception until we can check 238 * Technically we should defer an exception until we can check
220 * that all entries contain an author. If any entry is missing 239 * that all entries contain an author. If any entry is missing
221 * an author, then a missing feed author element is invalid 240 * an author, then a missing feed author element is invalid
222 */ 241 */
250 * @param DOMDocument $dom 269 * @param DOMDocument $dom
251 * @param DOMElement $root 270 * @param DOMElement $root
252 * @return void 271 * @return void
253 * @throws Writer\Exception\InvalidArgumentException 272 * @throws Writer\Exception\InvalidArgumentException
254 */ 273 */
274 // @codingStandardsIgnoreStart
255 protected function _setId(DOMDocument $dom, DOMElement $root) 275 protected function _setId(DOMDocument $dom, DOMElement $root)
256 { 276 {
257 if (!$this->getDataContainer()->getId() 277 // @codingStandardsIgnoreEnd
258 && !$this->getDataContainer()->getLink()) { 278 if (! $this->getDataContainer()->getId()
279 && ! $this->getDataContainer()->getLink()) {
259 $message = 'Atom 1.0 feed elements MUST contain exactly one ' 280 $message = 'Atom 1.0 feed elements MUST contain exactly one '
260 . 'atom:id element, or as an alternative, we can use the same ' 281 . 'atom:id element, or as an alternative, we can use the same '
261 . 'value as atom:link however neither a suitable link nor an ' 282 . 'value as atom:link however neither a suitable link nor an '
262 . 'id have been set'; 283 . 'id have been set';
263 $exception = new Writer\Exception\InvalidArgumentException($message); 284 $exception = new Writer\Exception\InvalidArgumentException($message);
264 if (!$this->ignoreExceptions) { 285 if (! $this->ignoreExceptions) {
265 throw $exception; 286 throw $exception;
266 } else { 287 } else {
267 $this->exceptions[] = $exception; 288 $this->exceptions[] = $exception;
268 return; 289 return;
269 } 290 }
270 } 291 }
271 292
272 if (!$this->getDataContainer()->getId()) { 293 if (! $this->getDataContainer()->getId()) {
273 $this->getDataContainer()->setId( 294 $this->getDataContainer()->setId(
274 $this->getDataContainer()->getLink()); 295 $this->getDataContainer()->getLink()
296 );
275 } 297 }
276 $id = $dom->createElement('id'); 298 $id = $dom->createElement('id');
277 $root->appendChild($id); 299 $root->appendChild($id);
278 $text = $dom->createTextNode($this->getDataContainer()->getId()); 300 $text = $dom->createTextNode($this->getDataContainer()->getId());
279 $id->appendChild($text); 301 $id->appendChild($text);
284 * 306 *
285 * @param DOMDocument $dom 307 * @param DOMDocument $dom
286 * @param DOMElement $root 308 * @param DOMElement $root
287 * @return void 309 * @return void
288 */ 310 */
311 // @codingStandardsIgnoreStart
289 protected function _setCopyright(DOMDocument $dom, DOMElement $root) 312 protected function _setCopyright(DOMDocument $dom, DOMElement $root)
290 { 313 {
314 // @codingStandardsIgnoreEnd
291 $copyright = $this->getDataContainer()->getCopyright(); 315 $copyright = $this->getDataContainer()->getCopyright();
292 if (!$copyright) { 316 if (! $copyright) {
293 return; 317 return;
294 } 318 }
295 $copy = $dom->createElement('rights'); 319 $copy = $dom->createElement('rights');
296 $root->appendChild($copy); 320 $root->appendChild($copy);
297 $text = $dom->createTextNode($copyright); 321 $text = $dom->createTextNode($copyright);
303 * 327 *
304 * @param DOMDocument $dom 328 * @param DOMDocument $dom
305 * @param DOMElement $root 329 * @param DOMElement $root
306 * @return void 330 * @return void
307 */ 331 */
332 // @codingStandardsIgnoreStart
308 protected function _setImage(DOMDocument $dom, DOMElement $root) 333 protected function _setImage(DOMDocument $dom, DOMElement $root)
309 { 334 {
335 // @codingStandardsIgnoreEnd
310 $image = $this->getDataContainer()->getImage(); 336 $image = $this->getDataContainer()->getImage();
311 if (!$image) { 337 if (! $image) {
312 return; 338 return;
313 } 339 }
314 $img = $dom->createElement('logo'); 340 $img = $dom->createElement('logo');
315 $root->appendChild($img); 341 $root->appendChild($img);
316 $text = $dom->createTextNode($image['uri']); 342 $text = $dom->createTextNode($image['uri']);
322 * 348 *
323 * @param DOMDocument $dom 349 * @param DOMDocument $dom
324 * @param DOMElement $root 350 * @param DOMElement $root
325 * @return void 351 * @return void
326 */ 352 */
353 // @codingStandardsIgnoreStart
327 protected function _setDateCreated(DOMDocument $dom, DOMElement $root) 354 protected function _setDateCreated(DOMDocument $dom, DOMElement $root)
328 { 355 {
329 if (!$this->getDataContainer()->getDateCreated()) { 356 // @codingStandardsIgnoreEnd
330 return; 357 if (! $this->getDataContainer()->getDateCreated()) {
331 } 358 return;
332 if (!$this->getDataContainer()->getDateModified()) { 359 }
360 if (! $this->getDataContainer()->getDateModified()) {
333 $this->getDataContainer()->setDateModified( 361 $this->getDataContainer()->setDateModified(
334 $this->getDataContainer()->getDateCreated() 362 $this->getDataContainer()->getDateCreated()
335 ); 363 );
336 } 364 }
337 } 365 }
341 * 369 *
342 * @param DOMDocument $dom 370 * @param DOMDocument $dom
343 * @param DOMElement $root 371 * @param DOMElement $root
344 * @return void 372 * @return void
345 */ 373 */
374 // @codingStandardsIgnoreStart
346 protected function _setBaseUrl(DOMDocument $dom, DOMElement $root) 375 protected function _setBaseUrl(DOMDocument $dom, DOMElement $root)
347 { 376 {
377 // @codingStandardsIgnoreEnd
348 $baseUrl = $this->getDataContainer()->getBaseUrl(); 378 $baseUrl = $this->getDataContainer()->getBaseUrl();
349 if (!$baseUrl) { 379 if (! $baseUrl) {
350 return; 380 return;
351 } 381 }
352 $root->setAttribute('xml:base', $baseUrl); 382 $root->setAttribute('xml:base', $baseUrl);
353 } 383 }
354 384
357 * 387 *
358 * @param DOMDocument $dom 388 * @param DOMDocument $dom
359 * @param DOMElement $root 389 * @param DOMElement $root
360 * @return void 390 * @return void
361 */ 391 */
392 // @codingStandardsIgnoreStart
362 protected function _setHubs(DOMDocument $dom, DOMElement $root) 393 protected function _setHubs(DOMDocument $dom, DOMElement $root)
363 { 394 {
395 // @codingStandardsIgnoreEnd
364 $hubs = $this->getDataContainer()->getHubs(); 396 $hubs = $this->getDataContainer()->getHubs();
365 if (!$hubs) { 397 if (! $hubs) {
366 return; 398 return;
367 } 399 }
368 foreach ($hubs as $hubUrl) { 400 foreach ($hubs as $hubUrl) {
369 $hub = $dom->createElement('link'); 401 $hub = $dom->createElement('link');
370 $hub->setAttribute('rel', 'hub'); 402 $hub->setAttribute('rel', 'hub');
378 * 410 *
379 * @param DOMDocument $dom 411 * @param DOMDocument $dom
380 * @param DOMElement $root 412 * @param DOMElement $root
381 * @return void 413 * @return void
382 */ 414 */
415 // @codingStandardsIgnoreStart
383 protected function _setCategories(DOMDocument $dom, DOMElement $root) 416 protected function _setCategories(DOMDocument $dom, DOMElement $root)
384 { 417 {
418 // @codingStandardsIgnoreEnd
385 $categories = $this->getDataContainer()->getCategories(); 419 $categories = $this->getDataContainer()->getCategories();
386 if (!$categories) { 420 if (! $categories) {
387 return; 421 return;
388 } 422 }
389 foreach ($categories as $cat) { 423 foreach ($categories as $cat) {
390 $category = $dom->createElement('category'); 424 $category = $dom->createElement('category');
391 $category->setAttribute('term', $cat['term']); 425 $category->setAttribute('term', $cat['term']);