@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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

+134 -1
+5
src/__phutil_library_map__.php
··· 4847 4847 'PhrictionContent' => 'applications/phriction/storage/PhrictionContent.php', 4848 4848 'PhrictionContentPHIDType' => 'applications/phriction/phid/PhrictionContentPHIDType.php', 4849 4849 'PhrictionContentQuery' => 'applications/phriction/query/PhrictionContentQuery.php', 4850 + 'PhrictionContentSearchConduitAPIMethod' => 'applications/phriction/conduit/PhrictionContentSearchConduitAPIMethod.php', 4851 + 'PhrictionContentSearchEngine' => 'applications/phriction/query/PhrictionContentSearchEngine.php', 4850 4852 'PhrictionController' => 'applications/phriction/controller/PhrictionController.php', 4851 4853 'PhrictionCreateConduitAPIMethod' => 'applications/phriction/conduit/PhrictionCreateConduitAPIMethod.php', 4852 4854 'PhrictionDAO' => 'applications/phriction/storage/PhrictionDAO.php', ··· 10759 10761 'PhrictionDAO', 10760 10762 'PhabricatorPolicyInterface', 10761 10763 'PhabricatorDestructibleInterface', 10764 + 'PhabricatorConduitResultInterface', 10762 10765 ), 10763 10766 'PhrictionContentPHIDType' => 'PhabricatorPHIDType', 10764 10767 'PhrictionContentQuery' => 'PhabricatorCursorPagedPolicyAwareQuery', 10768 + 'PhrictionContentSearchConduitAPIMethod' => 'PhabricatorSearchEngineAPIMethod', 10769 + 'PhrictionContentSearchEngine' => 'PhabricatorApplicationSearchEngine', 10765 10770 'PhrictionController' => 'PhabricatorController', 10766 10771 'PhrictionCreateConduitAPIMethod' => 'PhrictionConduitAPIMethod', 10767 10772 'PhrictionDAO' => 'PhabricatorLiskDAO',
+18
src/applications/phriction/conduit/PhrictionContentSearchConduitAPIMethod.php
··· 1 + <?php 2 + 3 + final class PhrictionContentSearchConduitAPIMethod 4 + extends PhabricatorSearchEngineAPIMethod { 5 + 6 + public function getAPIMethodName() { 7 + return 'phriction.content.search'; 8 + } 9 + 10 + public function newSearchEngine() { 11 + return new PhrictionContentSearchEngine(); 12 + } 13 + 14 + public function getMethodSummary() { 15 + return pht('Read information about Phriction document history.'); 16 + } 17 + 18 + }
+76
src/applications/phriction/query/PhrictionContentSearchEngine.php
··· 1 + <?php 2 + 3 + final class PhrictionContentSearchEngine 4 + extends PhabricatorApplicationSearchEngine { 5 + 6 + public function getResultTypeDescription() { 7 + return pht('Phriction Document Content'); 8 + } 9 + 10 + public function getApplicationClassName() { 11 + return 'PhabricatorPhrictionApplication'; 12 + } 13 + 14 + public function newQuery() { 15 + return new PhrictionContentQuery(); 16 + } 17 + 18 + protected function buildQueryFromParameters(array $map) { 19 + $query = $this->newQuery(); 20 + 21 + if ($map['documentPHIDs']) { 22 + $query->withDocumentPHIDs($map['documentPHIDs']); 23 + } 24 + 25 + if ($map['versions']) { 26 + $query->withVersions($map['versions']); 27 + } 28 + 29 + return $query; 30 + } 31 + 32 + protected function buildCustomSearchFields() { 33 + return array( 34 + id(new PhabricatorPHIDsSearchField()) 35 + ->setKey('documentPHIDs') 36 + ->setAliases(array('document', 'documents', 'documentPHID')) 37 + ->setLabel(pht('Documents')), 38 + id(new PhabricatorIDsSearchField()) 39 + ->setKey('versions') 40 + ->setAliases(array('version')), 41 + ); 42 + } 43 + 44 + protected function getURI($path) { 45 + // There's currently no web UI for this search interface, it exists purely 46 + // to power the Conduit API. 47 + throw new PhutilMethodNotImplementedException(); 48 + } 49 + 50 + protected function getBuiltinQueryNames() { 51 + return array( 52 + 'all' => pht('All Content'), 53 + ); 54 + } 55 + 56 + public function buildSavedQueryFromBuiltin($query_key) { 57 + $query = $this->newSavedQuery(); 58 + $query->setQueryKey($query_key); 59 + 60 + switch ($query_key) { 61 + case 'all': 62 + return $query; 63 + } 64 + 65 + return parent::buildSavedQueryFromBuiltin($query_key); 66 + } 67 + 68 + protected function renderResultList( 69 + array $contents, 70 + PhabricatorSavedQuery $query, 71 + array $handles) { 72 + assert_instances_of($contents, 'PhrictionContent'); 73 + throw new PhutilMethodNotImplementedException(); 74 + } 75 + 76 + }
+35 -1
src/applications/phriction/storage/PhrictionContent.php
··· 4 4 extends PhrictionDAO 5 5 implements 6 6 PhabricatorPolicyInterface, 7 - PhabricatorDestructibleInterface { 7 + PhabricatorDestructibleInterface, 8 + PhabricatorConduitResultInterface { 8 9 9 10 protected $documentID; 10 11 protected $version; ··· 101 102 public function destroyObjectPermanently( 102 103 PhabricatorDestructionEngine $engine) { 103 104 $this->delete(); 105 + } 106 + 107 + 108 + /* -( PhabricatorConduitResultInterface )---------------------------------- */ 109 + 110 + 111 + public function getFieldSpecificationsForConduit() { 112 + return array( 113 + id(new PhabricatorConduitSearchFieldSpecification()) 114 + ->setKey('documentPHID') 115 + ->setType('phid') 116 + ->setDescription(pht('Document this content is for.')), 117 + id(new PhabricatorConduitSearchFieldSpecification()) 118 + ->setKey('version') 119 + ->setType('int') 120 + ->setDescription(pht('Content version.')), 121 + id(new PhabricatorConduitSearchFieldSpecification()) 122 + ->setKey('authorPHID') 123 + ->setType('phid') 124 + ->setDescription(pht('Author of this version of the content.')), 125 + ); 126 + } 127 + 128 + public function getFieldValuesForConduit() { 129 + return array( 130 + 'documentPHID' => $this->getDocument()->getPHID(), 131 + 'version' => (int)$this->getVersion(), 132 + 'authorPHID' => $this->getAuthorPHID(), 133 + ); 134 + } 135 + 136 + public function getConduitSearchAttachments() { 137 + return array(); 104 138 } 105 139 106 140 }