comparison vendor/zendframework/zend-feed/src/Writer/Renderer/Entry/Rss.php @ 12:7a779792577d

Update Drupal core to v8.4.5 (via Composer)
author Chris Cannam
date Fri, 23 Feb 2018 15:52:07 +0000
parents 4c8ae668cc8c
children af1871eacc83
comparison
equal deleted inserted replaced
11:bfffd8d7479a 12:7a779792577d
54 $this->_setCommentLink($this->dom, $entry); 54 $this->_setCommentLink($this->dom, $entry);
55 $this->_setCategories($this->dom, $entry); 55 $this->_setCategories($this->dom, $entry);
56 foreach ($this->extensions as $ext) { 56 foreach ($this->extensions as $ext) {
57 $ext->setType($this->getType()); 57 $ext->setType($this->getType());
58 $ext->setRootElement($this->getRootElement()); 58 $ext->setRootElement($this->getRootElement());
59 $ext->setDOMDocument($this->getDOMDocument(), $entry); 59 $ext->setDomDocument($this->getDomDocument(), $entry);
60 $ext->render(); 60 $ext->render();
61 } 61 }
62 62
63 return $this; 63 return $this;
64 } 64 }
69 * @param DOMDocument $dom 69 * @param DOMDocument $dom
70 * @param DOMElement $root 70 * @param DOMElement $root
71 * @return void 71 * @return void
72 * @throws Writer\Exception\InvalidArgumentException 72 * @throws Writer\Exception\InvalidArgumentException
73 */ 73 */
74 // @codingStandardsIgnoreStart
74 protected function _setTitle(DOMDocument $dom, DOMElement $root) 75 protected function _setTitle(DOMDocument $dom, DOMElement $root)
75 { 76 {
76 if (!$this->getDataContainer()->getDescription() 77 // @codingStandardsIgnoreEnd
77 && !$this->getDataContainer()->getTitle()) { 78 if (! $this->getDataContainer()->getDescription()
79 && ! $this->getDataContainer()->getTitle()) {
78 $message = 'RSS 2.0 entry elements SHOULD contain exactly one' 80 $message = 'RSS 2.0 entry elements SHOULD contain exactly one'
79 . ' title element but a title has not been set. In addition, there' 81 . ' title element but a title has not been set. In addition, there'
80 . ' is no description as required in the absence of a title.'; 82 . ' is no description as required in the absence of a title.';
81 $exception = new Writer\Exception\InvalidArgumentException($message); 83 $exception = new Writer\Exception\InvalidArgumentException($message);
82 if (!$this->ignoreExceptions) { 84 if (! $this->ignoreExceptions) {
83 throw $exception; 85 throw $exception;
84 } else { 86 } else {
85 $this->exceptions[] = $exception; 87 $this->exceptions[] = $exception;
86 return; 88 return;
87 } 89 }
98 * @param DOMDocument $dom 100 * @param DOMDocument $dom
99 * @param DOMElement $root 101 * @param DOMElement $root
100 * @return void 102 * @return void
101 * @throws Writer\Exception\InvalidArgumentException 103 * @throws Writer\Exception\InvalidArgumentException
102 */ 104 */
105 // @codingStandardsIgnoreStart
103 protected function _setDescription(DOMDocument $dom, DOMElement $root) 106 protected function _setDescription(DOMDocument $dom, DOMElement $root)
104 { 107 {
105 if (!$this->getDataContainer()->getDescription() 108 // @codingStandardsIgnoreEnd
106 && !$this->getDataContainer()->getTitle()) { 109 if (! $this->getDataContainer()->getDescription()
110 && ! $this->getDataContainer()->getTitle()) {
107 $message = 'RSS 2.0 entry elements SHOULD contain exactly one' 111 $message = 'RSS 2.0 entry elements SHOULD contain exactly one'
108 . ' description element but a description has not been set. In' 112 . ' description element but a description has not been set. In'
109 . ' addition, there is no title element as required in the absence' 113 . ' addition, there is no title element as required in the absence'
110 . ' of a description.'; 114 . ' of a description.';
111 $exception = new Writer\Exception\InvalidArgumentException($message); 115 $exception = new Writer\Exception\InvalidArgumentException($message);
112 if (!$this->ignoreExceptions) { 116 if (! $this->ignoreExceptions) {
113 throw $exception; 117 throw $exception;
114 } else { 118 } else {
115 $this->exceptions[] = $exception; 119 $this->exceptions[] = $exception;
116 return; 120 return;
117 } 121 }
118 } 122 }
119 if (!$this->getDataContainer()->getDescription()) { 123 if (! $this->getDataContainer()->getDescription()) {
120 return; 124 return;
121 } 125 }
122 $subtitle = $dom->createElement('description'); 126 $subtitle = $dom->createElement('description');
123 $root->appendChild($subtitle); 127 $root->appendChild($subtitle);
124 $text = $dom->createCDATASection($this->getDataContainer()->getDescription()); 128 $text = $dom->createCDATASection($this->getDataContainer()->getDescription());
130 * 134 *
131 * @param DOMDocument $dom 135 * @param DOMDocument $dom
132 * @param DOMElement $root 136 * @param DOMElement $root
133 * @return void 137 * @return void
134 */ 138 */
139 // @codingStandardsIgnoreStart
135 protected function _setDateModified(DOMDocument $dom, DOMElement $root) 140 protected function _setDateModified(DOMDocument $dom, DOMElement $root)
136 { 141 {
137 if (!$this->getDataContainer()->getDateModified()) { 142 // @codingStandardsIgnoreEnd
143 if (! $this->getDataContainer()->getDateModified()) {
138 return; 144 return;
139 } 145 }
140 146
141 $updated = $dom->createElement('pubDate'); 147 $updated = $dom->createElement('pubDate');
142 $root->appendChild($updated); 148 $root->appendChild($updated);
151 * 157 *
152 * @param DOMDocument $dom 158 * @param DOMDocument $dom
153 * @param DOMElement $root 159 * @param DOMElement $root
154 * @return void 160 * @return void
155 */ 161 */
162 // @codingStandardsIgnoreStart
156 protected function _setDateCreated(DOMDocument $dom, DOMElement $root) 163 protected function _setDateCreated(DOMDocument $dom, DOMElement $root)
157 { 164 {
158 if (!$this->getDataContainer()->getDateCreated()) { 165 // @codingStandardsIgnoreEnd
159 return; 166 if (! $this->getDataContainer()->getDateCreated()) {
160 } 167 return;
161 if (!$this->getDataContainer()->getDateModified()) { 168 }
169 if (! $this->getDataContainer()->getDateModified()) {
162 $this->getDataContainer()->setDateModified( 170 $this->getDataContainer()->setDateModified(
163 $this->getDataContainer()->getDateCreated() 171 $this->getDataContainer()->getDateCreated()
164 ); 172 );
165 } 173 }
166 } 174 }
170 * 178 *
171 * @param DOMDocument $dom 179 * @param DOMDocument $dom
172 * @param DOMElement $root 180 * @param DOMElement $root
173 * @return void 181 * @return void
174 */ 182 */
183 // @codingStandardsIgnoreStart
175 protected function _setAuthors(DOMDocument $dom, DOMElement $root) 184 protected function _setAuthors(DOMDocument $dom, DOMElement $root)
176 { 185 {
186 // @codingStandardsIgnoreEnd
177 $authors = $this->container->getAuthors(); 187 $authors = $this->container->getAuthors();
178 if ((!$authors || empty($authors))) { 188 if ((! $authors || empty($authors))) {
179 return; 189 return;
180 } 190 }
181 foreach ($authors as $data) { 191 foreach ($authors as $data) {
182 $author = $this->dom->createElement('author'); 192 $author = $this->dom->createElement('author');
183 $name = $data['name']; 193 $name = $data['name'];
196 * @param DOMDocument $dom 206 * @param DOMDocument $dom
197 * @param DOMElement $root 207 * @param DOMElement $root
198 * @return void 208 * @return void
199 * @throws Writer\Exception\InvalidArgumentException 209 * @throws Writer\Exception\InvalidArgumentException
200 */ 210 */
211 // @codingStandardsIgnoreStart
201 protected function _setEnclosure(DOMDocument $dom, DOMElement $root) 212 protected function _setEnclosure(DOMDocument $dom, DOMElement $root)
202 { 213 {
214 // @codingStandardsIgnoreEnd
203 $data = $this->container->getEnclosure(); 215 $data = $this->container->getEnclosure();
204 if ((!$data || empty($data))) { 216 if ((! $data || empty($data))) {
205 return; 217 return;
206 } 218 }
207 if (!isset($data['type'])) { 219 if (! isset($data['type'])) {
208 $exception = new Writer\Exception\InvalidArgumentException('Enclosure "type" is not set'); 220 $exception = new Writer\Exception\InvalidArgumentException('Enclosure "type" is not set');
209 if (!$this->ignoreExceptions) { 221 if (! $this->ignoreExceptions) {
210 throw $exception; 222 throw $exception;
211 } else { 223 } else {
212 $this->exceptions[] = $exception; 224 $this->exceptions[] = $exception;
213 return; 225 return;
214 } 226 }
215 } 227 }
216 if (!isset($data['length'])) { 228 if (! isset($data['length'])) {
217 $exception = new Writer\Exception\InvalidArgumentException('Enclosure "length" is not set'); 229 $exception = new Writer\Exception\InvalidArgumentException('Enclosure "length" is not set');
218 if (!$this->ignoreExceptions) { 230 if (! $this->ignoreExceptions) {
219 throw $exception; 231 throw $exception;
220 } else { 232 } else {
221 $this->exceptions[] = $exception; 233 $this->exceptions[] = $exception;
222 return; 234 return;
223 } 235 }
224 } 236 }
225 if ((int) $data['length'] < 0 || !ctype_digit((string) $data['length'])) { 237 if ((int) $data['length'] < 0 || ! ctype_digit((string) $data['length'])) {
226 $exception = new Writer\Exception\InvalidArgumentException('Enclosure "length" must be an integer' 238 $exception = new Writer\Exception\InvalidArgumentException('Enclosure "length" must be an integer'
227 . ' indicating the content\'s length in bytes'); 239 . ' indicating the content\'s length in bytes');
228 if (!$this->ignoreExceptions) { 240 if (! $this->ignoreExceptions) {
229 throw $exception; 241 throw $exception;
230 } else { 242 } else {
231 $this->exceptions[] = $exception; 243 $this->exceptions[] = $exception;
232 return; 244 return;
233 } 245 }
244 * 256 *
245 * @param DOMDocument $dom 257 * @param DOMDocument $dom
246 * @param DOMElement $root 258 * @param DOMElement $root
247 * @return void 259 * @return void
248 */ 260 */
261 // @codingStandardsIgnoreStart
249 protected function _setLink(DOMDocument $dom, DOMElement $root) 262 protected function _setLink(DOMDocument $dom, DOMElement $root)
250 { 263 {
251 if (!$this->getDataContainer()->getLink()) { 264 // @codingStandardsIgnoreEnd
265 if (! $this->getDataContainer()->getLink()) {
252 return; 266 return;
253 } 267 }
254 $link = $dom->createElement('link'); 268 $link = $dom->createElement('link');
255 $root->appendChild($link); 269 $root->appendChild($link);
256 $text = $dom->createTextNode($this->getDataContainer()->getLink()); 270 $text = $dom->createTextNode($this->getDataContainer()->getLink());
262 * 276 *
263 * @param DOMDocument $dom 277 * @param DOMDocument $dom
264 * @param DOMElement $root 278 * @param DOMElement $root
265 * @return void 279 * @return void
266 */ 280 */
281 // @codingStandardsIgnoreStart
267 protected function _setId(DOMDocument $dom, DOMElement $root) 282 protected function _setId(DOMDocument $dom, DOMElement $root)
268 { 283 {
269 if (!$this->getDataContainer()->getId() 284 // @codingStandardsIgnoreEnd
270 && !$this->getDataContainer()->getLink()) { 285 if (! $this->getDataContainer()->getId()
286 && ! $this->getDataContainer()->getLink()) {
271 return; 287 return;
272 } 288 }
273 289
274 $id = $dom->createElement('guid'); 290 $id = $dom->createElement('guid');
275 $root->appendChild($id); 291 $root->appendChild($id);
276 if (!$this->getDataContainer()->getId()) { 292 if (! $this->getDataContainer()->getId()) {
277 $this->getDataContainer()->setId( 293 $this->getDataContainer()->setId(
278 $this->getDataContainer()->getLink()); 294 $this->getDataContainer()->getLink()
295 );
279 } 296 }
280 $text = $dom->createTextNode($this->getDataContainer()->getId()); 297 $text = $dom->createTextNode($this->getDataContainer()->getId());
281 $id->appendChild($text); 298 $id->appendChild($text);
282 if (!Uri::factory($this->getDataContainer()->getId())->isValid()) { 299 if (! Uri::factory($this->getDataContainer()->getId())->isValid()) {
283 $id->setAttribute('isPermaLink', 'false'); 300 $id->setAttribute('isPermaLink', 'false');
284 } 301 }
285 } 302 }
286 303
287 /** 304 /**
289 * 306 *
290 * @param DOMDocument $dom 307 * @param DOMDocument $dom
291 * @param DOMElement $root 308 * @param DOMElement $root
292 * @return void 309 * @return void
293 */ 310 */
311 // @codingStandardsIgnoreStart
294 protected function _setCommentLink(DOMDocument $dom, DOMElement $root) 312 protected function _setCommentLink(DOMDocument $dom, DOMElement $root)
295 { 313 {
314 // @codingStandardsIgnoreEnd
296 $link = $this->getDataContainer()->getCommentLink(); 315 $link = $this->getDataContainer()->getCommentLink();
297 if (!$link) { 316 if (! $link) {
298 return; 317 return;
299 } 318 }
300 $clink = $this->dom->createElement('comments'); 319 $clink = $this->dom->createElement('comments');
301 $text = $dom->createTextNode($link); 320 $text = $dom->createTextNode($link);
302 $clink->appendChild($text); 321 $clink->appendChild($text);
308 * 327 *
309 * @param DOMDocument $dom 328 * @param DOMDocument $dom
310 * @param DOMElement $root 329 * @param DOMElement $root
311 * @return void 330 * @return void
312 */ 331 */
332 // @codingStandardsIgnoreStart
313 protected function _setCategories(DOMDocument $dom, DOMElement $root) 333 protected function _setCategories(DOMDocument $dom, DOMElement $root)
314 { 334 {
335 // @codingStandardsIgnoreEnd
315 $categories = $this->getDataContainer()->getCategories(); 336 $categories = $this->getDataContainer()->getCategories();
316 if (!$categories) { 337 if (! $categories) {
317 return; 338 return;
318 } 339 }
319 foreach ($categories as $cat) { 340 foreach ($categories as $cat) {
320 $category = $dom->createElement('category'); 341 $category = $dom->createElement('category');
321 if (isset($cat['scheme'])) { 342 if (isset($cat['scheme'])) {