From b74f93f229d405995b2a6dd9e6fe28b231a3181f Mon Sep 17 00:00:00 2001 From: epriestley Date: Mon, 28 Dec 2015 03:58:43 -0800 Subject: [PATCH] Add phame.blog.search Conduit API endpoint Summary: Ref T9897. Adds basic blog query support. Test Plan: Ran some queries. Reviewers: chad Reviewed By: chad Maniphest Tasks: T9897 Differential Revision: https://secure.phabricator.com/D14900 --- src/__phutil_library_map__.php | 3 ++ .../PhameBlogSearchConduitAPIMethod.php | 18 ++++++++++ src/applications/phame/storage/PhameBlog.php | 36 ++++++++++++++++++- .../PhabricatorSearchEngineAPIMethod.php | 4 +++ 4 files changed, 60 insertions(+), 1 deletion(-) create mode 100644 src/applications/phame/conduit/PhameBlogSearchConduitAPIMethod.php diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php index 4898e6874c..19f1e74f05 100644 --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -3413,6 +3413,7 @@ phutil_register_library_map(array( 'PhameBlogProfilePictureController' => 'applications/phame/controller/blog/PhameBlogProfilePictureController.php', 'PhameBlogQuery' => 'applications/phame/query/PhameBlogQuery.php', 'PhameBlogReplyHandler' => 'applications/phame/mail/PhameBlogReplyHandler.php', + 'PhameBlogSearchConduitAPIMethod' => 'applications/phame/conduit/PhameBlogSearchConduitAPIMethod.php', 'PhameBlogSearchEngine' => 'applications/phame/query/PhameBlogSearchEngine.php', 'PhameBlogSite' => 'applications/phame/site/PhameBlogSite.php', 'PhameBlogTransaction' => 'applications/phame/storage/PhameBlogTransaction.php', @@ -7846,6 +7847,7 @@ phutil_register_library_map(array( 'PhabricatorProjectInterface', 'PhabricatorDestructibleInterface', 'PhabricatorApplicationTransactionInterface', + 'PhabricatorConduitResultInterface', ), 'PhameBlogArchiveController' => 'PhameBlogController', 'PhameBlogController' => 'PhameController', @@ -7861,6 +7863,7 @@ phutil_register_library_map(array( 'PhameBlogProfilePictureController' => 'PhameBlogController', 'PhameBlogQuery' => 'PhabricatorCursorPagedPolicyAwareQuery', 'PhameBlogReplyHandler' => 'PhabricatorApplicationTransactionReplyHandler', + 'PhameBlogSearchConduitAPIMethod' => 'PhabricatorSearchEngineAPIMethod', 'PhameBlogSearchEngine' => 'PhabricatorApplicationSearchEngine', 'PhameBlogSite' => 'PhameSite', 'PhameBlogTransaction' => 'PhabricatorApplicationTransaction', diff --git a/src/applications/phame/conduit/PhameBlogSearchConduitAPIMethod.php b/src/applications/phame/conduit/PhameBlogSearchConduitAPIMethod.php new file mode 100644 index 0000000000..e122f8a7a3 --- /dev/null +++ b/src/applications/phame/conduit/PhameBlogSearchConduitAPIMethod.php @@ -0,0 +1,18 @@ +setKey('name') + ->setType('string') + ->setDescription(pht('The name of the blog.')), + id(new PhabricatorConduitSearchFieldSpecification()) + ->setKey('description') + ->setType('string') + ->setDescription(pht('Blog description.')), + id(new PhabricatorConduitSearchFieldSpecification()) + ->setKey('status') + ->setType('string') + ->setDescription(pht('Archived or active status.')), + ); + } + + public function getFieldValuesForConduit() { + return array( + 'name' => $this->getName(), + 'description' => $this->getDescription(), + 'status' => $this->getStatus(), + ); + } + + public function getConduitSearchAttachments() { + return array(); + } + + } diff --git a/src/applications/search/engine/PhabricatorSearchEngineAPIMethod.php b/src/applications/search/engine/PhabricatorSearchEngineAPIMethod.php index 998a77126b..f411c208bf 100644 --- a/src/applications/search/engine/PhabricatorSearchEngineAPIMethod.php +++ b/src/applications/search/engine/PhabricatorSearchEngineAPIMethod.php @@ -15,6 +15,10 @@ abstract class PhabricatorSearchEngineAPIMethod } } + if (!$maps) { + $maps = (object)$maps; + } + return $maps; }