Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F15410078
D19097.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
5 KB
Referenced Files
None
Subscribers
None
D19097.diff
View Options
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 @@
+<?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.');
+ }
+
+}
diff --git a/src/applications/phriction/query/PhrictionContentSearchEngine.php b/src/applications/phriction/query/PhrictionContentSearchEngine.php
new file mode 100644
--- /dev/null
+++ b/src/applications/phriction/query/PhrictionContentSearchEngine.php
@@ -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();
+ }
+
+}
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();
+ }
+
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Thu, Mar 20, 6:45 AM (1 d, 21 h ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7472428
Default Alt Text
D19097.diff (5 KB)
Attached To
Mode
D19097: Introduce a "phriction.content.search" API method to replace "phriction.history"
Attached
Detach File
Event Timeline
Log In to Comment