123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243 |
- <?php
- namespace Grav\Plugin\Sitemap;
- class SitemapEntry
- {
- public $title;
- public $lang;
- public $translated = false;
- public $location;
- public $lastmod;
- public $changefreq;
- public $priority;
- public $images;
- public $hreflangs = [];
- /**
- * SitemapEntry constructor.
- *
- * @param null $location
- * @param null $lastmod
- * @param null $changefreq
- * @param null $priority
- * @param null $images
- */
- public function __construct($location = null, $lastmod = null, $changefreq = null, $priority = null, $images = null)
- {
- $this->location = $location;
- $this->lastmod = $lastmod;
- $this->changefreq = $changefreq;
- $this->priority = $priority;
- $this->images = $images;
- }
- /**
- * @param array $data
- * @return SitemapEntry
- */
- public function setData(array $data): SitemapEntry
- {
- foreach($data as $property => $value)
- {
- if (property_exists($this, $property)) {
- $this->{$property} = $value;
- }
- }
- return $this;
- }
- /**
- * @return mixed
- */
- public function getLang()
- {
- return $this->lang;
- }
- /**
- * @param mixed $lang
- * @return SitemapEntry
- */
- public function setLang($lang)
- {
- $this->lang = $lang;
- return $this;
- }
- /**
- * @return mixed
- */
- public function getTitle()
- {
- return $this->title;
- }
- /**
- * @param mixed $title
- * @return SitemapEntry
- */
- public function setTitle($title): SitemapEntry
- {
- $this->title = $title;
- return $this;
- }
- /**
- * @return mixed
- */
- public function getBaseLang()
- {
- return $this->base_lang;
- }
- /**
- * @param mixed $base_lang
- * @return SitemapEntry
- */
- public function setBaseLang($base_lang): SitemapEntry
- {
- $this->base_lang = $base_lang;
- return $this;
- }
- /**
- * @return bool
- */
- public function isTranslated(): bool
- {
- return $this->translated;
- }
- /**
- * @param bool $translated
- * @return SitemapEntry
- */
- public function setTranslated(bool $translated): SitemapEntry
- {
- $this->translated = $translated;
- return $this;
- }
- /**
- * @return null
- */
- public function getLocation()
- {
- return $this->location;
- }
- /**
- * @param null $location
- * @return SitemapEntry
- */
- public function setLocation($location): SitemapEntry
- {
- $this->location = $location;
- return $this;
- }
- /**
- * @return null
- */
- public function getLastmod()
- {
- return $this->lastmod;
- }
- /**
- * @param null $lastmod
- * @return SitemapEntry
- */
- public function setLastmod($lastmod): SitemapEntry
- {
- $this->lastmod = $lastmod;
- return $this;
- }
- /**
- * @return null
- */
- public function getChangefreq()
- {
- return $this->changefreq;
- }
- /**
- * @param null $changefreq
- * @return SitemapEntry
- */
- public function setChangefreq($changefreq): SitemapEntry
- {
- $this->changefreq = $changefreq;
- return $this;
- }
- /**
- * @return null
- */
- public function getPriority()
- {
- return $this->priority;
- }
- /**
- * @param null $priority
- * @return SitemapEntry
- */
- public function setPriority($priority): SitemapEntry
- {
- $this->priority = $priority;
- return $this;
- }
- /**
- * @return null
- */
- public function getImages()
- {
- return $this->images;
- }
- /**
- * @param null $images
- * @return SitemapEntry
- */
- public function setImages($images)
- {
- $this->images = $images;
- return $this;
- }
- /**
- * @return array
- */
- public function getHreflangs(): array
- {
- return $this->hreflangs;
- }
- /**
- * @param array $hreflang
- * @return SitemapEntry
- */
- public function addHreflangs(array $hreflang): SitemapEntry
- {
- $this->hreflangs[] = $hreflang;
- return $this;
- }
- /**
- * @param array $hreflangs
- * @return SitemapEntry
- */
- public function setHreflangs(array $hreflangs): SitemapEntry
- {
- $this->hreflangs = $hreflangs;
- return $this;
- }
- }
|