44
55use Ominity \Api \Resources \BaseResource ;
66use Ominity \Api \Resources \ResourceFactory ;
7+ use Ominity \Api \Types \PageStatus ;
78
89class Page extends BaseResource
910{
@@ -35,6 +36,13 @@ class Page extends BaseResource
3536 */
3637 public $ slug ;
3738
39+ /**
40+ * Status of the page.
41+ *
42+ * @var string
43+ */
44+ public $ status ;
45+
3846 /**
3947 * Page meta data for SEO puposes.
4048 *
@@ -99,20 +107,33 @@ class Page extends BaseResource
99107 public $ _links ;
100108
101109 /**
102- * Is this page published ?
110+ * Is this page a draft ?
103111 *
104112 * @return bool
105113 */
106- public function isPublished ()
114+ public function isDraft ()
107115 {
108- if (is_null ($ this ->publishedAt )) {
109- return false ;
110- }
116+ return $ this ->status === PageStatus::DRAFT ;
117+ }
111118
112- $ publishedTimestamp = strtotime ($ this ->publishedAt );
113- $ currentTimestamp = time ();
119+ /**
120+ * Is this page scheduled?
121+ *
122+ * @return bool
123+ */
124+ public function isScheduled ()
125+ {
126+ return $ this ->status === PageStatus::SCHEDULED ;
127+ }
114128
115- return $ publishedTimestamp <= $ currentTimestamp ;
129+ /**
130+ * Is this page published?
131+ *
132+ * @return bool
133+ */
134+ public function isPublished ()
135+ {
136+ return $ this ->status === PageStatus::PUBLISHED ;
116137 }
117138
118139 /**
@@ -121,6 +142,14 @@ public function isPublished()
121142 */
122143 public function layout ()
123144 {
145+ if (isset ($ this ->_embedded , $ this ->_embedded ->layout ))
146+ {
147+ return ResourceFactory::createFromApiResult (
148+ $ this ->_embedded ->layout ,
149+ new Layout ($ this ->client )
150+ );
151+ }
152+
124153 return $ this ->client ->cms ->layouts ->get ($ this ->layoutId );
125154 }
126155
0 commit comments