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\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::ATOM));
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 // @codingStandardsIgnoreStart
59 protected function _setComment(DOMDocument $dom, DOMElement $root)
61 // @codingStandardsIgnoreEnd
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 // @codingStandardsIgnoreStart
80 protected function _setBy(DOMDocument $dom, DOMElement $root)
82 // @codingStandardsIgnoreEnd
83 $data = $this->container->getBy();
84 if ((! $data || empty($data))) {
87 $author = $this->dom->createElement('at:by');
88 $name = $this->dom->createElement('name');
89 $author->appendChild($name);
90 $root->appendChild($author);
91 $text = $dom->createTextNode($data['name']);
92 $name->appendChild($text);
93 if (array_key_exists('email', $data)) {
94 $email = $this->dom->createElement('email');
95 $author->appendChild($email);
96 $text = $dom->createTextNode($data['email']);
97 $email->appendChild($text);
99 if (array_key_exists('uri', $data)) {
100 $uri = $this->dom->createElement('uri');
101 $author->appendChild($uri);
102 $text = $dom->createTextNode($data['uri']);
103 $uri->appendChild($text);