db backup prior to drupal security update
[yaffs-website] / vendor / zendframework / zend-feed / src / Writer / Renderer / Entry / AtomDeleted.php
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     // @codingStandardsIgnoreStart
61     protected function _setComment(DOMDocument $dom, DOMElement $root)
62     {
63         // @codingStandardsIgnoreEnd
64         if (! $this->getDataContainer()->getComment()) {
65             return;
66         }
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);
72     }
73
74     /**
75      * Set entry authors
76      *
77      * @param  DOMDocument $dom
78      * @param  DOMElement $root
79      * @return void
80      */
81     // @codingStandardsIgnoreStart
82     protected function _setBy(DOMDocument $dom, DOMElement $root)
83     {
84         // @codingStandardsIgnoreEnd
85         $data = $this->container->getBy();
86         if ((! $data || empty($data))) {
87             return;
88         }
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);
100         }
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);
106         }
107     }
108 }