3 * Zend Framework (http://framework.zend.com/)
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
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::ATOM));
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 // @codingStandardsIgnoreStart
61 protected function _setComment(DOMDocument $dom, DOMElement $root)
63 // @codingStandardsIgnoreEnd
64 if (! $this->getDataContainer()->getComment()) {
67 $c = $dom->createElement('at:comment');
68 $root->appendChild($c);
69 $c->setAttribute('type', 'html');
70 $cdata = $dom->createCDATASection($this->getDataContainer()->getComment());
71 $c->appendChild($cdata);
77 * @param DOMDocument $dom
78 * @param DOMElement $root
81 // @codingStandardsIgnoreStart
82 protected function _setBy(DOMDocument $dom, DOMElement $root)
84 // @codingStandardsIgnoreEnd
85 $data = $this->container->getBy();
86 if ((! $data || empty($data))) {
89 $author = $this->dom->createElement('at:by');
90 $name = $this->dom->createElement('name');
91 $author->appendChild($name);
92 $root->appendChild($author);
93 $text = $dom->createTextNode($data['name']);
94 $name->appendChild($text);
95 if (array_key_exists('email', $data)) {
96 $email = $this->dom->createElement('email');
97 $author->appendChild($email);
98 $text = $dom->createTextNode($data['email']);
99 $email->appendChild($text);
101 if (array_key_exists('uri', $data)) {
102 $uri = $this->dom->createElement('uri');
103 $author->appendChild($uri);
104 $text = $dom->createTextNode($data['uri']);
105 $uri->appendChild($text);