3 * Zend Framework (http://framework.zend.com/)
5 * @link http://github.com/zendframework/zf2 for the canonical source repository
6 * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
7 * @license http://framework.zend.com/license/new-bsd New BSD License
10 namespace Zend\Feed\Writer\Renderer\Entry\Atom
;
16 use Zend\Feed\Writer\Renderer
;
18 class Deleted
extends Renderer\AbstractRenderer
implements Renderer\RendererInterface
23 * @param Writer\Deleted $container
25 public function __construct(Writer\Deleted
$container)
27 parent
::__construct($container);
33 * @return Writer\Renderer\Entry\Atom
35 public function render()
37 $this->dom
= new DOMDocument('1.0', $this->container
->getEncoding());
38 $this->dom
->formatOutput
= true;
39 $entry = $this->dom
->createElement('at:deleted-entry');
40 $this->dom
->appendChild($entry);
42 $entry->setAttribute('ref', $this->container
->getReference());
43 $entry->setAttribute('when', $this->container
->getWhen()->format(DateTime
::ISO8601
));
45 $this->_setBy($this->dom
, $entry);
46 $this->_setComment($this->dom
, $entry);
52 * Set tombstone comment
54 * @param DOMDocument $dom
55 * @param DOMElement $root
58 protected function _setComment(DOMDocument
$dom, DOMElement
$root)
60 if (!$this->getDataContainer()->getComment()) {
63 $c = $dom->createElement('at:comment');
64 $root->appendChild($c);
65 $c->setAttribute('type', 'html');
66 $cdata = $dom->createCDATASection($this->getDataContainer()->getComment());
67 $c->appendChild($cdata);
73 * @param DOMDocument $dom
74 * @param DOMElement $root
77 protected function _setBy(DOMDocument
$dom, DOMElement
$root)
79 $data = $this->container
->getBy();
80 if ((!$data ||
empty($data))) {
83 $author = $this->dom
->createElement('at:by');
84 $name = $this->dom
->createElement('name');
85 $author->appendChild($name);
86 $root->appendChild($author);
87 $text = $dom->createTextNode($data['name']);
88 $name->appendChild($text);
89 if (array_key_exists('email', $data)) {
90 $email = $this->dom
->createElement('email');
91 $author->appendChild($email);
92 $text = $dom->createTextNode($data['email']);
93 $email->appendChild($text);
95 if (array_key_exists('uri', $data)) {
96 $uri = $this->dom
->createElement('uri');
97 $author->appendChild($uri);
98 $text = $dom->createTextNode($data['uri']);
99 $uri->appendChild($text);