From c6adb877351773a1ee4dbbf37c65562041e9abdb Mon Sep 17 00:00:00 2001 From: Martin Albert Date: Mon, 28 Oct 2024 14:04:02 +0100 Subject: [PATCH] feat: add getters --- src/ButterCMS/Model/Page.php | 30 +++++++++++ src/ButterCMS/Model/Post.php | 80 ++++++++++++++++++++++++++++ src/ButterCMS/Model/PostResponse.php | 5 ++ 3 files changed, 115 insertions(+) diff --git a/src/ButterCMS/Model/Page.php b/src/ButterCMS/Model/Page.php index 8ce3a7f..5de2d48 100644 --- a/src/ButterCMS/Model/Page.php +++ b/src/ButterCMS/Model/Page.php @@ -12,6 +12,36 @@ class Page extends Model protected $status; protected $scheduled; + public function getSlug() + { + return $this->slug; + } + + public function getPageType() + { + return $this->page_type; + } + + public function getPublished() + { + return $this->published; + } + + public function getUpdated() + { + return $this->updated; + } + + public function getStatus() + { + return $this->status; + } + + public function getScheduled() + { + return $this->scheduled; + } + public function getField($fieldName, $default = null) { return isset($this->fields[$fieldName]) ? $this->fields[$fieldName] : $default; diff --git a/src/ButterCMS/Model/Post.php b/src/ButterCMS/Model/Post.php index 60d7066..2a02a93 100644 --- a/src/ButterCMS/Model/Post.php +++ b/src/ButterCMS/Model/Post.php @@ -47,6 +47,86 @@ public function __construct(array $data) parent::__construct($data); } + public function getSlug() + { + return $this->slug; + } + + public function getUrl() + { + return $this->url; + } + + public function getPublished() + { + return $this->published; + } + + public function getCreated() + { + return $this->created; + } + + public function getStatus() + { + return $this->status; + } + + public function getScheduled() + { + return $this->scheduled; + } + + public function getTitle() + { + return $this->title; + } + + public function getBody() + { + return $this->body; + } + + public function getSummary() + { + return $this->summary; + } + + public function getSeoTitle() + { + return $this->seo_title; + } + + public function getMetaDescription() + { + return $this->meta_description; + } + + public function getAuthor() + { + return $this->author; + } + + public function getCategories() + { + return $this->categories; + } + + public function getTags() + { + return $this->tags; + } + + public function getFeaturedImage() + { + return $this->featured_image; + } + + public function getFeaturedImageAlt() + { + return $this->featured_image_alt; + } + public function isPublished() { return 'published' === $this->status; diff --git a/src/ButterCMS/Model/PostResponse.php b/src/ButterCMS/Model/PostResponse.php index dd41846..fc5bf23 100644 --- a/src/ButterCMS/Model/PostResponse.php +++ b/src/ButterCMS/Model/PostResponse.php @@ -15,4 +15,9 @@ public function __construct(array $dataArray) parent::__construct($dataArray); } + + public function getPost() + { + return $this->post; + } }