mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-03 12:12:43 +01:00
Introduce a "phriction.content.search" API method to replace "phriction.history"
Summary: Depends on D19096. Ref T13077. Adds a new "v3" API method for Phriction document content, to replace the existing "phriction.history" call. Test Plan: Made various calls via web API console. Maniphest Tasks: T13077 Differential Revision: https://secure.phabricator.com/D19097
This commit is contained in:
parent
a965d8d6ae
commit
8101bf74e9
4 changed files with 134 additions and 1 deletions
|
@ -4847,6 +4847,8 @@ phutil_register_library_map(array(
|
||||||
'PhrictionContent' => 'applications/phriction/storage/PhrictionContent.php',
|
'PhrictionContent' => 'applications/phriction/storage/PhrictionContent.php',
|
||||||
'PhrictionContentPHIDType' => 'applications/phriction/phid/PhrictionContentPHIDType.php',
|
'PhrictionContentPHIDType' => 'applications/phriction/phid/PhrictionContentPHIDType.php',
|
||||||
'PhrictionContentQuery' => 'applications/phriction/query/PhrictionContentQuery.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',
|
'PhrictionController' => 'applications/phriction/controller/PhrictionController.php',
|
||||||
'PhrictionCreateConduitAPIMethod' => 'applications/phriction/conduit/PhrictionCreateConduitAPIMethod.php',
|
'PhrictionCreateConduitAPIMethod' => 'applications/phriction/conduit/PhrictionCreateConduitAPIMethod.php',
|
||||||
'PhrictionDAO' => 'applications/phriction/storage/PhrictionDAO.php',
|
'PhrictionDAO' => 'applications/phriction/storage/PhrictionDAO.php',
|
||||||
|
@ -10759,9 +10761,12 @@ phutil_register_library_map(array(
|
||||||
'PhrictionDAO',
|
'PhrictionDAO',
|
||||||
'PhabricatorPolicyInterface',
|
'PhabricatorPolicyInterface',
|
||||||
'PhabricatorDestructibleInterface',
|
'PhabricatorDestructibleInterface',
|
||||||
|
'PhabricatorConduitResultInterface',
|
||||||
),
|
),
|
||||||
'PhrictionContentPHIDType' => 'PhabricatorPHIDType',
|
'PhrictionContentPHIDType' => 'PhabricatorPHIDType',
|
||||||
'PhrictionContentQuery' => 'PhabricatorCursorPagedPolicyAwareQuery',
|
'PhrictionContentQuery' => 'PhabricatorCursorPagedPolicyAwareQuery',
|
||||||
|
'PhrictionContentSearchConduitAPIMethod' => 'PhabricatorSearchEngineAPIMethod',
|
||||||
|
'PhrictionContentSearchEngine' => 'PhabricatorApplicationSearchEngine',
|
||||||
'PhrictionController' => 'PhabricatorController',
|
'PhrictionController' => 'PhabricatorController',
|
||||||
'PhrictionCreateConduitAPIMethod' => 'PhrictionConduitAPIMethod',
|
'PhrictionCreateConduitAPIMethod' => 'PhrictionConduitAPIMethod',
|
||||||
'PhrictionDAO' => 'PhabricatorLiskDAO',
|
'PhrictionDAO' => 'PhabricatorLiskDAO',
|
||||||
|
|
|
@ -0,0 +1,18 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
final class PhrictionContentSearchConduitAPIMethod
|
||||||
|
extends PhabricatorSearchEngineAPIMethod {
|
||||||
|
|
||||||
|
public function getAPIMethodName() {
|
||||||
|
return 'phriction.content.search';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function newSearchEngine() {
|
||||||
|
return new PhrictionContentSearchEngine();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getMethodSummary() {
|
||||||
|
return pht('Read information about Phriction document history.');
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,76 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
final class PhrictionContentSearchEngine
|
||||||
|
extends PhabricatorApplicationSearchEngine {
|
||||||
|
|
||||||
|
public function getResultTypeDescription() {
|
||||||
|
return pht('Phriction Document Content');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getApplicationClassName() {
|
||||||
|
return 'PhabricatorPhrictionApplication';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function newQuery() {
|
||||||
|
return new PhrictionContentQuery();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function buildQueryFromParameters(array $map) {
|
||||||
|
$query = $this->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();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -4,7 +4,8 @@ final class PhrictionContent
|
||||||
extends PhrictionDAO
|
extends PhrictionDAO
|
||||||
implements
|
implements
|
||||||
PhabricatorPolicyInterface,
|
PhabricatorPolicyInterface,
|
||||||
PhabricatorDestructibleInterface {
|
PhabricatorDestructibleInterface,
|
||||||
|
PhabricatorConduitResultInterface {
|
||||||
|
|
||||||
protected $documentID;
|
protected $documentID;
|
||||||
protected $version;
|
protected $version;
|
||||||
|
@ -103,4 +104,37 @@ final class PhrictionContent
|
||||||
$this->delete();
|
$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();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue