diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -4847,6 +4847,8 @@ 'PhrictionContent' => 'applications/phriction/storage/PhrictionContent.php', 'PhrictionContentPHIDType' => 'applications/phriction/phid/PhrictionContentPHIDType.php', 'PhrictionContentQuery' => 'applications/phriction/query/PhrictionContentQuery.php', + 'PhrictionContentSearchConduitAPIMethod' => 'applications/phriction/conduit/PhrictionContentSearchConduitAPIMethod.php', + 'PhrictionContentSearchEngine' => 'applications/phriction/query/PhrictionContentSearchEngine.php', 'PhrictionController' => 'applications/phriction/controller/PhrictionController.php', 'PhrictionCreateConduitAPIMethod' => 'applications/phriction/conduit/PhrictionCreateConduitAPIMethod.php', 'PhrictionDAO' => 'applications/phriction/storage/PhrictionDAO.php', @@ -10759,9 +10761,12 @@ 'PhrictionDAO', 'PhabricatorPolicyInterface', 'PhabricatorDestructibleInterface', + 'PhabricatorConduitResultInterface', ), 'PhrictionContentPHIDType' => 'PhabricatorPHIDType', 'PhrictionContentQuery' => 'PhabricatorCursorPagedPolicyAwareQuery', + 'PhrictionContentSearchConduitAPIMethod' => 'PhabricatorSearchEngineAPIMethod', + 'PhrictionContentSearchEngine' => 'PhabricatorApplicationSearchEngine', 'PhrictionController' => 'PhabricatorController', 'PhrictionCreateConduitAPIMethod' => 'PhrictionConduitAPIMethod', 'PhrictionDAO' => 'PhabricatorLiskDAO', diff --git a/src/applications/phriction/conduit/PhrictionContentSearchConduitAPIMethod.php b/src/applications/phriction/conduit/PhrictionContentSearchConduitAPIMethod.php new file mode 100644 --- /dev/null +++ b/src/applications/phriction/conduit/PhrictionContentSearchConduitAPIMethod.php @@ -0,0 +1,18 @@ +newQuery(); + + if ($map['documentPHIDs']) { + $query->withDocumentPHIDs($map['documentPHIDs']); + } + + if ($map['versions']) { + $query->withVersions($map['versions']); + } + + return $query; + } + + protected function buildCustomSearchFields() { + return array( + id(new PhabricatorPHIDsSearchField()) + ->setKey('documentPHIDs') + ->setAliases(array('document', 'documents', 'documentPHID')) + ->setLabel(pht('Documents')), + id(new PhabricatorIDsSearchField()) + ->setKey('versions') + ->setAliases(array('version')), + ); + } + + protected function getURI($path) { + // There's currently no web UI for this search interface, it exists purely + // to power the Conduit API. + throw new PhutilMethodNotImplementedException(); + } + + protected function getBuiltinQueryNames() { + return array( + 'all' => pht('All Content'), + ); + } + + public function buildSavedQueryFromBuiltin($query_key) { + $query = $this->newSavedQuery(); + $query->setQueryKey($query_key); + + switch ($query_key) { + case 'all': + return $query; + } + + return parent::buildSavedQueryFromBuiltin($query_key); + } + + protected function renderResultList( + array $contents, + PhabricatorSavedQuery $query, + array $handles) { + assert_instances_of($contents, 'PhrictionContent'); + throw new PhutilMethodNotImplementedException(); + } + +} diff --git a/src/applications/phriction/storage/PhrictionContent.php b/src/applications/phriction/storage/PhrictionContent.php --- a/src/applications/phriction/storage/PhrictionContent.php +++ b/src/applications/phriction/storage/PhrictionContent.php @@ -4,7 +4,8 @@ extends PhrictionDAO implements PhabricatorPolicyInterface, - PhabricatorDestructibleInterface { + PhabricatorDestructibleInterface, + PhabricatorConduitResultInterface { protected $documentID; protected $version; @@ -103,4 +104,37 @@ $this->delete(); } + +/* -( PhabricatorConduitResultInterface )---------------------------------- */ + + + public function getFieldSpecificationsForConduit() { + return array( + id(new PhabricatorConduitSearchFieldSpecification()) + ->setKey('documentPHID') + ->setType('phid') + ->setDescription(pht('Document this content is for.')), + id(new PhabricatorConduitSearchFieldSpecification()) + ->setKey('version') + ->setType('int') + ->setDescription(pht('Content version.')), + id(new PhabricatorConduitSearchFieldSpecification()) + ->setKey('authorPHID') + ->setType('phid') + ->setDescription(pht('Author of this version of the content.')), + ); + } + + public function getFieldValuesForConduit() { + return array( + 'documentPHID' => $this->getDocument()->getPHID(), + 'version' => (int)$this->getVersion(), + 'authorPHID' => $this->getAuthorPHID(), + ); + } + + public function getConduitSearchAttachments() { + return array(); + } + }