@@ -9,7 +9,8 @@ final class PhamePost extends PhameDAO
9
9
PhabricatorApplicationTransactionInterface,
10
10
PhabricatorSubscribableInterface,
11
11
PhabricatorDestructibleInterface,
12
- PhabricatorTokenReceiverInterface {
12
+ PhabricatorTokenReceiverInterface,
13
+ PhabricatorConduitResultInterface {
13
14
14
15
const MARKUP_FIELD_BODY = 'markup:body ' ;
15
16
const MARKUP_FIELD_SUMMARY = 'markup:summary ' ;
@@ -24,7 +25,7 @@ final class PhamePost extends PhameDAO
24
25
protected $ blogPHID ;
25
26
protected $ mailKey ;
26
27
27
- private $ blog ;
28
+ private $ blog = self :: ATTACHABLE ;
28
29
29
30
public static function initializePost (
30
31
PhabricatorUser $ blogger ,
@@ -33,19 +34,20 @@ public static function initializePost(
33
34
$ post = id (new PhamePost ())
34
35
->setBloggerPHID ($ blogger ->getPHID ())
35
36
->setBlogPHID ($ blog ->getPHID ())
36
- ->setBlog ($ blog )
37
+ ->attachBlog ($ blog )
37
38
->setDatePublished (PhabricatorTime::getNow ())
38
39
->setVisibility (PhameConstants::VISIBILITY_PUBLISHED );
40
+
39
41
return $ post ;
40
42
}
41
43
42
- public function setBlog (PhameBlog $ blog ) {
44
+ public function attachBlog (PhameBlog $ blog ) {
43
45
$ this ->blog = $ blog ;
44
46
return $ this ;
45
47
}
46
48
47
49
public function getBlog () {
48
- return $ this ->blog ;
50
+ return $ this ->assertAttached ( $ this -> blog ) ;
49
51
}
50
52
51
53
public function getLiveURI () {
@@ -146,21 +148,6 @@ public function getSlug() {
146
148
return PhabricatorSlug::normalizeProjectSlug ($ this ->getTitle (), true );
147
149
}
148
150
149
- public function toDictionary () {
150
- return array (
151
- 'id ' => $ this ->getID (),
152
- 'phid ' => $ this ->getPHID (),
153
- 'blogPHID ' => $ this ->getBlogPHID (),
154
- 'bloggerPHID ' => $ this ->getBloggerPHID (),
155
- 'viewURI ' => $ this ->getViewURI (),
156
- 'title ' => $ this ->getTitle (),
157
- 'body ' => $ this ->getBody (),
158
- 'summary ' => PhabricatorMarkupEngine::summarize ($ this ->getBody ()),
159
- 'datePublished ' => $ this ->getDatePublished (),
160
- 'published ' => !$ this ->isDraft (),
161
- );
162
- }
163
-
164
151
165
152
/* -( PhabricatorPolicyInterface Implementation )-------------------------- */
166
153
@@ -303,4 +290,59 @@ public function shouldAllowSubscription($phid) {
303
290
return true ;
304
291
}
305
292
293
+
294
+ /* -( PhabricatorConduitResultInterface )---------------------------------- */
295
+
296
+
297
+ public function getFieldSpecificationsForConduit () {
298
+ return array (
299
+ id (new PhabricatorConduitSearchFieldSpecification ())
300
+ ->setKey ('title ' )
301
+ ->setType ('string ' )
302
+ ->setDescription (pht ('Title of the post. ' )),
303
+ id (new PhabricatorConduitSearchFieldSpecification ())
304
+ ->setKey ('slug ' )
305
+ ->setType ('string ' )
306
+ ->setDescription (pht ('Slug for the post. ' )),
307
+ id (new PhabricatorConduitSearchFieldSpecification ())
308
+ ->setKey ('blogPHID ' )
309
+ ->setType ('phid ' )
310
+ ->setDescription (pht ('PHID of the blog that the post belongs to. ' )),
311
+ id (new PhabricatorConduitSearchFieldSpecification ())
312
+ ->setKey ('authorPHID ' )
313
+ ->setType ('phid ' )
314
+ ->setDescription (pht ('PHID of the author of the post. ' )),
315
+ id (new PhabricatorConduitSearchFieldSpecification ())
316
+ ->setKey ('body ' )
317
+ ->setType ('string ' )
318
+ ->setDescription (pht ('Body of the post. ' )),
319
+ id (new PhabricatorConduitSearchFieldSpecification ())
320
+ ->setKey ('datePublished ' )
321
+ ->setType ('epoch? ' )
322
+ ->setDescription (pht ('Publish date, if the post has been published. ' )),
323
+
324
+ );
325
+ }
326
+
327
+ public function getFieldValuesForConduit () {
328
+ if ($ this ->isDraft ()) {
329
+ $ date_published = null ;
330
+ } else {
331
+ $ date_published = (int )$ this ->getDatePublished ();
332
+ }
333
+
334
+ return array (
335
+ 'title ' => $ this ->getTitle (),
336
+ 'slug ' => $ this ->getSlug (),
337
+ 'blogPHID ' => $ this ->getBlogPHID (),
338
+ 'authorPHID ' => $ this ->getBloggerPHID (),
339
+ 'body ' => $ this ->getBody (),
340
+ 'datePublished ' => $ date_published ,
341
+ );
342
+ }
343
+
344
+ public function getConduitSearchAttachments () {
345
+ return array ();
346
+ }
347
+
306
348
}
0 commit comments