[ Index ] |
PHP Cross Reference of Phabricator |
[Summary view] [Print] [Text view]
1 <?php 2 3 final class PhameQueryPostsConduitAPIMethod extends PhameConduitAPIMethod { 4 5 public function getAPIMethodName() { 6 return 'phame.queryposts'; 7 } 8 9 public function getMethodDescription() { 10 return 'Query phame posts.'; 11 } 12 13 public function getMethodStatus() { 14 return self::METHOD_STATUS_UNSTABLE; 15 } 16 17 public function defineParamTypes() { 18 return array( 19 'ids' => 'optional list<int>', 20 'phids' => 'optional list<phid>', 21 'blogPHIDs' => 'optional list<phid>', 22 'bloggerPHIDs' => 'optional list<phid>', 23 'phameTitles' => 'optional list<string>', 24 'published' => 'optional bool', 25 'publishedAfter' => 'optional date', 26 'before' => 'optional int', 27 'after' => 'optional int', 28 'limit' => 'optional int', 29 ); 30 } 31 32 public function defineReturnType() { 33 return 'list<dict>'; 34 } 35 36 public function defineErrorTypes() { 37 return array( 38 ); 39 } 40 41 protected function execute(ConduitAPIRequest $request) { 42 $query = new PhamePostQuery(); 43 44 $query->setViewer($request->getUser()); 45 46 $ids = $request->getValue('ids', array()); 47 if ($ids) { 48 $query->withIDs($ids); 49 } 50 51 $phids = $request->getValue('phids', array()); 52 if ($phids) { 53 $query->withPHIDs($phids); 54 } 55 56 $blog_phids = $request->getValue('blogPHIDs', array()); 57 if ($blog_phids) { 58 $query->withBlogPHIDs($blog_phids); 59 } 60 61 $blogger_phids = $request->getValue('bloggerPHIDs', array()); 62 if ($blogger_phids) { 63 $query->withBloggerPHIDs($blogger_phids); 64 } 65 66 $phame_titles = $request->getValue('phameTitles', array()); 67 if ($phame_titles) { 68 $query->withPhameTitles($phame_titles); 69 } 70 71 $published = $request->getValue('published', null); 72 if ($published === true) { 73 $query->withVisibility(PhamePost::VISIBILITY_PUBLISHED); 74 } else if ($published === false) { 75 $query->withVisibility(PhamePost::VISIBILITY_DRAFT); 76 } 77 78 $published_after = $request->getValue('publishedAfter', null); 79 if ($published_after !== null) { 80 $query->withPublishedAfter($published_after); 81 } 82 83 $after = $request->getValue('after', null); 84 if ($after !== null) { 85 $query->setAfterID($after); 86 } 87 88 $before = $request->getValue('before', null); 89 if ($before !== null) { 90 $query->setBeforeID($before); 91 } 92 93 $limit = $request->getValue('limit', null); 94 if ($limit !== null) { 95 $query->setLimit($limit); 96 } 97 98 $posts = $query->execute(); 99 100 $results = array(); 101 foreach ($posts as $post) { 102 $results[] = $post->toDictionary(); 103 } 104 105 return $results; 106 } 107 108 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Sun Nov 30 09:20:46 2014 | Cross-referenced by PHPXref 0.7.1 |