Mercurial > hg > isophonics-drupal-site
comparison vendor/zendframework/zend-feed/src/Writer/Renderer/Entry/AtomDeleted.php @ 0:4c8ae668cc8c
Initial import (non-working)
author | Chris Cannam |
---|---|
date | Wed, 29 Nov 2017 16:09:58 +0000 |
parents | |
children | 7a779792577d |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:4c8ae668cc8c |
---|---|
1 <?php | |
2 /** | |
3 * Zend Framework (http://framework.zend.com/) | |
4 * | |
5 * @link http://github.com/zendframework/zf2 for the canonical source repository | |
6 * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) | |
7 * @license http://framework.zend.com/license/new-bsd New BSD License | |
8 */ | |
9 | |
10 namespace Zend\Feed\Writer\Renderer\Entry; | |
11 | |
12 use DateTime; | |
13 use DOMDocument; | |
14 use DOMElement; | |
15 use Zend\Feed\Writer; | |
16 use Zend\Feed\Writer\Renderer; | |
17 | |
18 /** | |
19 */ | |
20 class AtomDeleted extends Renderer\AbstractRenderer implements Renderer\RendererInterface | |
21 { | |
22 /** | |
23 * Constructor | |
24 * | |
25 * @param Writer\Deleted $container | |
26 */ | |
27 public function __construct(Writer\Deleted $container) | |
28 { | |
29 parent::__construct($container); | |
30 } | |
31 | |
32 /** | |
33 * Render atom entry | |
34 * | |
35 * @return \Zend\Feed\Writer\Renderer\Entry\Atom | |
36 */ | |
37 public function render() | |
38 { | |
39 $this->dom = new DOMDocument('1.0', $this->container->getEncoding()); | |
40 $this->dom->formatOutput = true; | |
41 $entry = $this->dom->createElement('at:deleted-entry'); | |
42 $this->dom->appendChild($entry); | |
43 | |
44 $entry->setAttribute('ref', $this->container->getReference()); | |
45 $entry->setAttribute('when', $this->container->getWhen()->format(DateTime::ATOM)); | |
46 | |
47 $this->_setBy($this->dom, $entry); | |
48 $this->_setComment($this->dom, $entry); | |
49 | |
50 return $this; | |
51 } | |
52 | |
53 /** | |
54 * Set tombstone comment | |
55 * | |
56 * @param DOMDocument $dom | |
57 * @param DOMElement $root | |
58 * @return void | |
59 */ | |
60 protected function _setComment(DOMDocument $dom, DOMElement $root) | |
61 { | |
62 if (!$this->getDataContainer()->getComment()) { | |
63 return; | |
64 } | |
65 $c = $dom->createElement('at:comment'); | |
66 $root->appendChild($c); | |
67 $c->setAttribute('type', 'html'); | |
68 $cdata = $dom->createCDATASection($this->getDataContainer()->getComment()); | |
69 $c->appendChild($cdata); | |
70 } | |
71 | |
72 /** | |
73 * Set entry authors | |
74 * | |
75 * @param DOMDocument $dom | |
76 * @param DOMElement $root | |
77 * @return void | |
78 */ | |
79 protected function _setBy(DOMDocument $dom, DOMElement $root) | |
80 { | |
81 $data = $this->container->getBy(); | |
82 if ((!$data || empty($data))) { | |
83 return; | |
84 } | |
85 $author = $this->dom->createElement('at:by'); | |
86 $name = $this->dom->createElement('name'); | |
87 $author->appendChild($name); | |
88 $root->appendChild($author); | |
89 $text = $dom->createTextNode($data['name']); | |
90 $name->appendChild($text); | |
91 if (array_key_exists('email', $data)) { | |
92 $email = $this->dom->createElement('email'); | |
93 $author->appendChild($email); | |
94 $text = $dom->createTextNode($data['email']); | |
95 $email->appendChild($text); | |
96 } | |
97 if (array_key_exists('uri', $data)) { | |
98 $uri = $this->dom->createElement('uri'); | |
99 $author->appendChild($uri); | |
100 $text = $dom->createTextNode($data['uri']); | |
101 $uri->appendChild($text); | |
102 } | |
103 } | |
104 } |