annotate vendor/zendframework/zend-feed/src/Reader/Extension/GooglePlayPodcast/Feed.php @ 5:12f9dff5fda9 tip

Update to Drupal core 8.7.1
author Chris Cannam
date Thu, 09 May 2019 15:34:47 +0100
parents 5311817fb629
children
rev   line source
Chris@2 1 <?php
Chris@2 2 /**
Chris@2 3 * @see https://github.com/zendframework/zend-feed for the canonical source repository
Chris@2 4 * @copyright Copyright (c) 2018 Zend Technologies USA Inc. (https://www.zend.com)
Chris@2 5 * @license https://github.com/zendframework/zend-feed/blob/master/LICENSE.md New BSD License
Chris@2 6 */
Chris@2 7
Chris@2 8 namespace Zend\Feed\Reader\Extension\GooglePlayPodcast;
Chris@2 9
Chris@2 10 use DOMText;
Chris@2 11 use Zend\Feed\Reader\Extension;
Chris@2 12
Chris@2 13 class Feed extends Extension\AbstractFeed
Chris@2 14 {
Chris@2 15 /**
Chris@2 16 * Get the entry author
Chris@2 17 *
Chris@2 18 * @return string
Chris@2 19 */
Chris@2 20 public function getPlayPodcastAuthor()
Chris@2 21 {
Chris@2 22 if (isset($this->data['author'])) {
Chris@2 23 return $this->data['author'];
Chris@2 24 }
Chris@2 25
Chris@2 26 $author = $this->xpath->evaluate('string(' . $this->getXpathPrefix() . '/googleplay:author)');
Chris@2 27
Chris@2 28 if (! $author) {
Chris@2 29 $author = null;
Chris@2 30 }
Chris@2 31
Chris@2 32 $this->data['author'] = $author;
Chris@2 33
Chris@2 34 return $this->data['author'];
Chris@2 35 }
Chris@2 36
Chris@2 37 /**
Chris@2 38 * Get the entry block
Chris@2 39 *
Chris@2 40 * @return string
Chris@2 41 */
Chris@2 42 public function getPlayPodcastBlock()
Chris@2 43 {
Chris@2 44 if (isset($this->data['block'])) {
Chris@2 45 return $this->data['block'];
Chris@2 46 }
Chris@2 47
Chris@2 48 $block = $this->xpath->evaluate('string(' . $this->getXpathPrefix() . '/googleplay:block)');
Chris@2 49
Chris@2 50 if (! $block) {
Chris@2 51 $block = null;
Chris@2 52 }
Chris@2 53
Chris@2 54 $this->data['block'] = $block;
Chris@2 55
Chris@2 56 return $this->data['block'];
Chris@2 57 }
Chris@2 58
Chris@2 59 /**
Chris@2 60 * Get the entry category
Chris@2 61 *
Chris@2 62 * @return array|null
Chris@2 63 */
Chris@2 64 public function getPlayPodcastCategories()
Chris@2 65 {
Chris@2 66 if (isset($this->data['categories'])) {
Chris@2 67 return $this->data['categories'];
Chris@2 68 }
Chris@2 69
Chris@2 70 $categoryList = $this->xpath->query($this->getXpathPrefix() . '/googleplay:category');
Chris@2 71
Chris@2 72 $categories = [];
Chris@2 73
Chris@2 74 if ($categoryList->length > 0) {
Chris@2 75 foreach ($categoryList as $node) {
Chris@2 76 $children = null;
Chris@2 77
Chris@2 78 if ($node->childNodes->length > 0) {
Chris@2 79 $children = [];
Chris@2 80
Chris@2 81 foreach ($node->childNodes as $childNode) {
Chris@2 82 if (! ($childNode instanceof DOMText)) {
Chris@2 83 $children[$childNode->getAttribute('text')] = null;
Chris@2 84 }
Chris@2 85 }
Chris@2 86 }
Chris@2 87
Chris@2 88 $categories[$node->getAttribute('text')] = $children;
Chris@2 89 }
Chris@2 90 }
Chris@2 91
Chris@2 92 if (! $categories) {
Chris@2 93 $categories = null;
Chris@2 94 }
Chris@2 95
Chris@2 96 $this->data['categories'] = $categories;
Chris@2 97
Chris@2 98 return $this->data['categories'];
Chris@2 99 }
Chris@2 100
Chris@2 101 /**
Chris@2 102 * Get the entry explicit
Chris@2 103 *
Chris@2 104 * @return string
Chris@2 105 */
Chris@2 106 public function getPlayPodcastExplicit()
Chris@2 107 {
Chris@2 108 if (isset($this->data['explicit'])) {
Chris@2 109 return $this->data['explicit'];
Chris@2 110 }
Chris@2 111
Chris@2 112 $explicit = $this->xpath->evaluate('string(' . $this->getXpathPrefix() . '/googleplay:explicit)');
Chris@2 113
Chris@2 114 if (! $explicit) {
Chris@2 115 $explicit = null;
Chris@2 116 }
Chris@2 117
Chris@2 118 $this->data['explicit'] = $explicit;
Chris@2 119
Chris@2 120 return $this->data['explicit'];
Chris@2 121 }
Chris@2 122
Chris@2 123 /**
Chris@2 124 * Get the feed/podcast image
Chris@2 125 *
Chris@2 126 * @return string
Chris@2 127 */
Chris@2 128 public function getPlayPodcastImage()
Chris@2 129 {
Chris@2 130 if (isset($this->data['image'])) {
Chris@2 131 return $this->data['image'];
Chris@2 132 }
Chris@2 133
Chris@2 134 $image = $this->xpath->evaluate('string(' . $this->getXpathPrefix() . '/googleplay:image/@href)');
Chris@2 135
Chris@2 136 if (! $image) {
Chris@2 137 $image = null;
Chris@2 138 }
Chris@2 139
Chris@2 140 $this->data['image'] = $image;
Chris@2 141
Chris@2 142 return $this->data['image'];
Chris@2 143 }
Chris@2 144
Chris@2 145 /**
Chris@2 146 * Get the entry description
Chris@2 147 *
Chris@2 148 * @return string
Chris@2 149 */
Chris@2 150 public function getPlayPodcastDescription()
Chris@2 151 {
Chris@2 152 if (isset($this->data['description'])) {
Chris@2 153 return $this->data['description'];
Chris@2 154 }
Chris@2 155
Chris@2 156 $description = $this->xpath->evaluate('string(' . $this->getXpathPrefix() . '/googleplay:description)');
Chris@2 157
Chris@2 158 if (! $description) {
Chris@2 159 $description = null;
Chris@2 160 }
Chris@2 161
Chris@2 162 $this->data['description'] = $description;
Chris@2 163
Chris@2 164 return $this->data['description'];
Chris@2 165 }
Chris@2 166
Chris@2 167 /**
Chris@2 168 * Register googleplay namespace
Chris@2 169 *
Chris@2 170 */
Chris@2 171 protected function registerNamespaces()
Chris@2 172 {
Chris@2 173 $this->xpath->registerNamespace('googleplay', 'http://www.google.com/schemas/play-podcasts/1.0');
Chris@2 174 }
Chris@2 175 }