SitemapEntry.php 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243
  1. <?php
  2. namespace Grav\Plugin\Sitemap;
  3. class SitemapEntry
  4. {
  5. public $title;
  6. public $lang;
  7. public $translated = false;
  8. public $location;
  9. public $lastmod;
  10. public $changefreq;
  11. public $priority;
  12. public $images;
  13. public $hreflangs = [];
  14. /**
  15. * SitemapEntry constructor.
  16. *
  17. * @param null $location
  18. * @param null $lastmod
  19. * @param null $changefreq
  20. * @param null $priority
  21. * @param null $images
  22. */
  23. public function __construct($location = null, $lastmod = null, $changefreq = null, $priority = null, $images = null)
  24. {
  25. $this->location = $location;
  26. $this->lastmod = $lastmod;
  27. $this->changefreq = $changefreq;
  28. $this->priority = $priority;
  29. $this->images = $images;
  30. }
  31. /**
  32. * @param array $data
  33. * @return SitemapEntry
  34. */
  35. public function setData(array $data): SitemapEntry
  36. {
  37. foreach($data as $property => $value)
  38. {
  39. if (property_exists($this, $property)) {
  40. $this->{$property} = $value;
  41. }
  42. }
  43. return $this;
  44. }
  45. /**
  46. * @return mixed
  47. */
  48. public function getLang()
  49. {
  50. return $this->lang;
  51. }
  52. /**
  53. * @param mixed $lang
  54. * @return SitemapEntry
  55. */
  56. public function setLang($lang)
  57. {
  58. $this->lang = $lang;
  59. return $this;
  60. }
  61. /**
  62. * @return mixed
  63. */
  64. public function getTitle()
  65. {
  66. return $this->title;
  67. }
  68. /**
  69. * @param mixed $title
  70. * @return SitemapEntry
  71. */
  72. public function setTitle($title): SitemapEntry
  73. {
  74. $this->title = $title;
  75. return $this;
  76. }
  77. /**
  78. * @return mixed
  79. */
  80. public function getBaseLang()
  81. {
  82. return $this->base_lang;
  83. }
  84. /**
  85. * @param mixed $base_lang
  86. * @return SitemapEntry
  87. */
  88. public function setBaseLang($base_lang): SitemapEntry
  89. {
  90. $this->base_lang = $base_lang;
  91. return $this;
  92. }
  93. /**
  94. * @return bool
  95. */
  96. public function isTranslated(): bool
  97. {
  98. return $this->translated;
  99. }
  100. /**
  101. * @param bool $translated
  102. * @return SitemapEntry
  103. */
  104. public function setTranslated(bool $translated): SitemapEntry
  105. {
  106. $this->translated = $translated;
  107. return $this;
  108. }
  109. /**
  110. * @return null
  111. */
  112. public function getLocation()
  113. {
  114. return $this->location;
  115. }
  116. /**
  117. * @param null $location
  118. * @return SitemapEntry
  119. */
  120. public function setLocation($location): SitemapEntry
  121. {
  122. $this->location = $location;
  123. return $this;
  124. }
  125. /**
  126. * @return null
  127. */
  128. public function getLastmod()
  129. {
  130. return $this->lastmod;
  131. }
  132. /**
  133. * @param null $lastmod
  134. * @return SitemapEntry
  135. */
  136. public function setLastmod($lastmod): SitemapEntry
  137. {
  138. $this->lastmod = $lastmod;
  139. return $this;
  140. }
  141. /**
  142. * @return null
  143. */
  144. public function getChangefreq()
  145. {
  146. return $this->changefreq;
  147. }
  148. /**
  149. * @param null $changefreq
  150. * @return SitemapEntry
  151. */
  152. public function setChangefreq($changefreq): SitemapEntry
  153. {
  154. $this->changefreq = $changefreq;
  155. return $this;
  156. }
  157. /**
  158. * @return null
  159. */
  160. public function getPriority()
  161. {
  162. return $this->priority;
  163. }
  164. /**
  165. * @param null $priority
  166. * @return SitemapEntry
  167. */
  168. public function setPriority($priority): SitemapEntry
  169. {
  170. $this->priority = $priority;
  171. return $this;
  172. }
  173. /**
  174. * @return null
  175. */
  176. public function getImages()
  177. {
  178. return $this->images;
  179. }
  180. /**
  181. * @param null $images
  182. * @return SitemapEntry
  183. */
  184. public function setImages($images)
  185. {
  186. $this->images = $images;
  187. return $this;
  188. }
  189. /**
  190. * @return array
  191. */
  192. public function getHreflangs(): array
  193. {
  194. return $this->hreflangs;
  195. }
  196. /**
  197. * @param array $hreflang
  198. * @return SitemapEntry
  199. */
  200. public function addHreflangs(array $hreflang): SitemapEntry
  201. {
  202. $this->hreflangs[] = $hreflang;
  203. return $this;
  204. }
  205. /**
  206. * @param array $hreflangs
  207. * @return SitemapEntry
  208. */
  209. public function setHreflangs(array $hreflangs): SitemapEntry
  210. {
  211. $this->hreflangs = $hreflangs;
  212. return $this;
  213. }
  214. }