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
;
16 use Zend\Feed\Writer\Renderer
;
20 class AtomDeleted
extends Renderer\AbstractRenderer
implements Renderer\RendererInterface
25 * @param Writer\Deleted $container
27 public function __construct(Writer\Deleted
$container)
29 parent
::__construct($container);
35 * @return \Zend\Feed\Writer\Renderer\Entry\Atom
37 public function render()
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);
44 $entry->setAttribute('ref', $this->container
->getReference());
45 $entry->setAttribute('when', $this->container
->getWhen()->format(DateTime
::ISO8601
));
47 $this->_setBy($this->dom
, $entry);
48 $this->_setComment($this->dom
, $entry);
54 * Set tombstone comment
56 * @param DOMDocument $dom
57 * @param DOMElement $root
60 protected function _setComment(DOMDocument
$dom, DOMElement
$root)
62 if (!$this->getDataContainer()->getComment()) {
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);
75 * @param DOMDocument $dom
76 * @param DOMElement $root
79 protected function _setBy(DOMDocument
$dom, DOMElement
$root)
81 $data = $this->container
->getBy();
82 if ((!$data ||
empty($data))) {
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);
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);