annotate vendor/zendframework/zend-feed/src/Writer/Renderer/Entry/AtomDeleted.php @ 3:e11175134f4e

Attempt to introduce editable version of theme
author Chris Cannam
date Tue, 05 Dec 2017 11:25:38 +0000
parents 4c8ae668cc8c
children 7a779792577d
rev   line source
Chris@0 1 <?php
Chris@0 2 /**
Chris@0 3 * Zend Framework (http://framework.zend.com/)
Chris@0 4 *
Chris@0 5 * @link http://github.com/zendframework/zf2 for the canonical source repository
Chris@0 6 * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
Chris@0 7 * @license http://framework.zend.com/license/new-bsd New BSD License
Chris@0 8 */
Chris@0 9
Chris@0 10 namespace Zend\Feed\Writer\Renderer\Entry;
Chris@0 11
Chris@0 12 use DateTime;
Chris@0 13 use DOMDocument;
Chris@0 14 use DOMElement;
Chris@0 15 use Zend\Feed\Writer;
Chris@0 16 use Zend\Feed\Writer\Renderer;
Chris@0 17
Chris@0 18 /**
Chris@0 19 */
Chris@0 20 class AtomDeleted extends Renderer\AbstractRenderer implements Renderer\RendererInterface
Chris@0 21 {
Chris@0 22 /**
Chris@0 23 * Constructor
Chris@0 24 *
Chris@0 25 * @param Writer\Deleted $container
Chris@0 26 */
Chris@0 27 public function __construct(Writer\Deleted $container)
Chris@0 28 {
Chris@0 29 parent::__construct($container);
Chris@0 30 }
Chris@0 31
Chris@0 32 /**
Chris@0 33 * Render atom entry
Chris@0 34 *
Chris@0 35 * @return \Zend\Feed\Writer\Renderer\Entry\Atom
Chris@0 36 */
Chris@0 37 public function render()
Chris@0 38 {
Chris@0 39 $this->dom = new DOMDocument('1.0', $this->container->getEncoding());
Chris@0 40 $this->dom->formatOutput = true;
Chris@0 41 $entry = $this->dom->createElement('at:deleted-entry');
Chris@0 42 $this->dom->appendChild($entry);
Chris@0 43
Chris@0 44 $entry->setAttribute('ref', $this->container->getReference());
Chris@0 45 $entry->setAttribute('when', $this->container->getWhen()->format(DateTime::ATOM));
Chris@0 46
Chris@0 47 $this->_setBy($this->dom, $entry);
Chris@0 48 $this->_setComment($this->dom, $entry);
Chris@0 49
Chris@0 50 return $this;
Chris@0 51 }
Chris@0 52
Chris@0 53 /**
Chris@0 54 * Set tombstone comment
Chris@0 55 *
Chris@0 56 * @param DOMDocument $dom
Chris@0 57 * @param DOMElement $root
Chris@0 58 * @return void
Chris@0 59 */
Chris@0 60 protected function _setComment(DOMDocument $dom, DOMElement $root)
Chris@0 61 {
Chris@0 62 if (!$this->getDataContainer()->getComment()) {
Chris@0 63 return;
Chris@0 64 }
Chris@0 65 $c = $dom->createElement('at:comment');
Chris@0 66 $root->appendChild($c);
Chris@0 67 $c->setAttribute('type', 'html');
Chris@0 68 $cdata = $dom->createCDATASection($this->getDataContainer()->getComment());
Chris@0 69 $c->appendChild($cdata);
Chris@0 70 }
Chris@0 71
Chris@0 72 /**
Chris@0 73 * Set entry authors
Chris@0 74 *
Chris@0 75 * @param DOMDocument $dom
Chris@0 76 * @param DOMElement $root
Chris@0 77 * @return void
Chris@0 78 */
Chris@0 79 protected function _setBy(DOMDocument $dom, DOMElement $root)
Chris@0 80 {
Chris@0 81 $data = $this->container->getBy();
Chris@0 82 if ((!$data || empty($data))) {
Chris@0 83 return;
Chris@0 84 }
Chris@0 85 $author = $this->dom->createElement('at:by');
Chris@0 86 $name = $this->dom->createElement('name');
Chris@0 87 $author->appendChild($name);
Chris@0 88 $root->appendChild($author);
Chris@0 89 $text = $dom->createTextNode($data['name']);
Chris@0 90 $name->appendChild($text);
Chris@0 91 if (array_key_exists('email', $data)) {
Chris@0 92 $email = $this->dom->createElement('email');
Chris@0 93 $author->appendChild($email);
Chris@0 94 $text = $dom->createTextNode($data['email']);
Chris@0 95 $email->appendChild($text);
Chris@0 96 }
Chris@0 97 if (array_key_exists('uri', $data)) {
Chris@0 98 $uri = $this->dom->createElement('uri');
Chris@0 99 $author->appendChild($uri);
Chris@0 100 $text = $dom->createTextNode($data['uri']);
Chris@0 101 $uri->appendChild($text);
Chris@0 102 }
Chris@0 103 }
Chris@0 104 }