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 @@ -236,6 +236,7 @@ 'ConduitMethodNotFoundException' => 'applications/conduit/protocol/exception/ConduitMethodNotFoundException.php', 'ConduitPingConduitAPIMethod' => 'applications/conduit/method/ConduitPingConduitAPIMethod.php', 'ConduitQueryConduitAPIMethod' => 'applications/conduit/method/ConduitQueryConduitAPIMethod.php', + 'ConduitResultSearchEngineExtension' => 'applications/conduit/query/ConduitResultSearchEngineExtension.php', 'ConduitSSHWorkflow' => 'applications/conduit/ssh/ConduitSSHWorkflow.php', 'ConduitTokenGarbageCollector' => 'applications/conduit/garbagecollector/ConduitTokenGarbageCollector.php', 'ConpherenceColumnViewController' => 'applications/conpherence/controller/ConpherenceColumnViewController.php', @@ -1557,6 +1558,7 @@ 'PasteMailReceiver' => 'applications/paste/mail/PasteMailReceiver.php', 'PasteQueryConduitAPIMethod' => 'applications/paste/conduit/PasteQueryConduitAPIMethod.php', 'PasteReplyHandler' => 'applications/paste/mail/PasteReplyHandler.php', + 'PasteSearchConduitAPIMethod' => 'applications/paste/conduit/PasteSearchConduitAPIMethod.php', 'PeopleBrowseUserDirectoryCapability' => 'applications/people/capability/PeopleBrowseUserDirectoryCapability.php', 'PeopleCreateUsersCapability' => 'applications/people/capability/PeopleCreateUsersCapability.php', 'PeopleUserLogGarbageCollector' => 'applications/people/garbagecollector/PeopleUserLogGarbageCollector.php', @@ -1880,6 +1882,7 @@ 'PhabricatorConduitMethodCallLog' => 'applications/conduit/storage/PhabricatorConduitMethodCallLog.php', 'PhabricatorConduitMethodQuery' => 'applications/conduit/query/PhabricatorConduitMethodQuery.php', 'PhabricatorConduitRequestExceptionHandler' => 'aphront/handler/PhabricatorConduitRequestExceptionHandler.php', + 'PhabricatorConduitResultInterface' => 'applications/conduit/interface/PhabricatorConduitResultInterface.php', 'PhabricatorConduitSearchEngine' => 'applications/conduit/query/PhabricatorConduitSearchEngine.php', 'PhabricatorConduitTestCase' => '__tests__/PhabricatorConduitTestCase.php', 'PhabricatorConduitToken' => 'applications/conduit/storage/PhabricatorConduitToken.php', @@ -2364,6 +2367,7 @@ 'PhabricatorLipsumManagementWorkflow' => 'applications/lipsum/management/PhabricatorLipsumManagementWorkflow.php', 'PhabricatorLipsumMondrianArtist' => 'applications/lipsum/image/PhabricatorLipsumMondrianArtist.php', 'PhabricatorLiskDAO' => 'infrastructure/storage/lisk/PhabricatorLiskDAO.php', + 'PhabricatorLiskSearchEngineExtension' => 'applications/search/engineextension/PhabricatorLiskSearchEngineExtension.php', 'PhabricatorLiskSerializer' => 'infrastructure/storage/lisk/PhabricatorLiskSerializer.php', 'PhabricatorListFilterUIExample' => 'applications/uiexample/examples/PhabricatorListFilterUIExample.php', 'PhabricatorLocalDiskFileStorageEngine' => 'applications/files/engine/PhabricatorLocalDiskFileStorageEngine.php', @@ -2745,6 +2749,7 @@ 'PhabricatorPolicyQuery' => 'applications/policy/query/PhabricatorPolicyQuery.php', 'PhabricatorPolicyRequestExceptionHandler' => 'aphront/handler/PhabricatorPolicyRequestExceptionHandler.php', 'PhabricatorPolicyRule' => 'applications/policy/rule/PhabricatorPolicyRule.php', + 'PhabricatorPolicySearchEngineExtension' => 'applications/policy/engineextension/PhabricatorPolicySearchEngineExtension.php', 'PhabricatorPolicyTestCase' => 'applications/policy/__tests__/PhabricatorPolicyTestCase.php', 'PhabricatorPolicyTestObject' => 'applications/policy/__tests__/PhabricatorPolicyTestObject.php', 'PhabricatorPolicyType' => 'applications/policy/constants/PhabricatorPolicyType.php', @@ -2980,6 +2985,9 @@ 'PhabricatorSearchDocumentTypeDatasource' => 'applications/search/typeahead/PhabricatorSearchDocumentTypeDatasource.php', 'PhabricatorSearchEditController' => 'applications/search/controller/PhabricatorSearchEditController.php', 'PhabricatorSearchEngine' => 'applications/search/engine/PhabricatorSearchEngine.php', + 'PhabricatorSearchEngineAPIMethod' => 'applications/search/engine/PhabricatorSearchEngineAPIMethod.php', + 'PhabricatorSearchEngineExtension' => 'applications/search/engineextension/PhabricatorSearchEngineExtension.php', + 'PhabricatorSearchEngineExtensionModule' => 'applications/search/engineextension/PhabricatorSearchEngineExtensionModule.php', 'PhabricatorSearchEngineTestCase' => 'applications/search/engine/__tests__/PhabricatorSearchEngineTestCase.php', 'PhabricatorSearchField' => 'applications/search/field/PhabricatorSearchField.php', 'PhabricatorSearchHovercardController' => 'applications/search/controller/PhabricatorSearchHovercardController.php', @@ -3067,6 +3075,7 @@ 'PhabricatorSpacesNoAccessController' => 'applications/spaces/controller/PhabricatorSpacesNoAccessController.php', 'PhabricatorSpacesRemarkupRule' => 'applications/spaces/remarkup/PhabricatorSpacesRemarkupRule.php', 'PhabricatorSpacesSchemaSpec' => 'applications/spaces/storage/PhabricatorSpacesSchemaSpec.php', + 'PhabricatorSpacesSearchEngineExtension' => 'applications/spaces/engineextension/PhabricatorSpacesSearchEngineExtension.php', 'PhabricatorSpacesSearchField' => 'applications/spaces/searchfield/PhabricatorSpacesSearchField.php', 'PhabricatorSpacesTestCase' => 'applications/spaces/__tests__/PhabricatorSpacesTestCase.php', 'PhabricatorSpacesViewController' => 'applications/spaces/controller/PhabricatorSpacesViewController.php', @@ -4063,6 +4072,7 @@ 'ConduitMethodNotFoundException' => 'ConduitException', 'ConduitPingConduitAPIMethod' => 'ConduitAPIMethod', 'ConduitQueryConduitAPIMethod' => 'ConduitAPIMethod', + 'ConduitResultSearchEngineExtension' => 'PhabricatorSearchEngineExtension', 'ConduitSSHWorkflow' => 'PhabricatorSSHWorkflow', 'ConduitTokenGarbageCollector' => 'PhabricatorGarbageCollector', 'ConpherenceColumnViewController' => 'ConpherenceController', @@ -5577,6 +5587,7 @@ 'PasteMailReceiver' => 'PhabricatorObjectMailReceiver', 'PasteQueryConduitAPIMethod' => 'PasteConduitAPIMethod', 'PasteReplyHandler' => 'PhabricatorApplicationTransactionReplyHandler', + 'PasteSearchConduitAPIMethod' => 'PhabricatorSearchEngineAPIMethod', 'PeopleBrowseUserDirectoryCapability' => 'PhabricatorPolicyCapability', 'PeopleCreateUsersCapability' => 'PhabricatorPolicyCapability', 'PeopleUserLogGarbageCollector' => 'PhabricatorGarbageCollector', @@ -5962,6 +5973,7 @@ ), 'PhabricatorConduitMethodQuery' => 'PhabricatorCursorPagedPolicyAwareQuery', 'PhabricatorConduitRequestExceptionHandler' => 'PhabricatorRequestExceptionHandler', + 'PhabricatorConduitResultInterface' => 'PhabricatorPHIDInterface', 'PhabricatorConduitSearchEngine' => 'PhabricatorApplicationSearchEngine', 'PhabricatorConduitTestCase' => 'PhabricatorTestCase', 'PhabricatorConduitToken' => array( @@ -6527,6 +6539,7 @@ 'PhabricatorLipsumManagementWorkflow' => 'PhabricatorManagementWorkflow', 'PhabricatorLipsumMondrianArtist' => 'PhabricatorLipsumArtist', 'PhabricatorLiskDAO' => 'LiskDAO', + 'PhabricatorLiskSearchEngineExtension' => 'PhabricatorSearchEngineExtension', 'PhabricatorLiskSerializer' => 'Phobject', 'PhabricatorListFilterUIExample' => 'PhabricatorUIExample', 'PhabricatorLocalDiskFileStorageEngine' => 'PhabricatorFileStorageEngine', @@ -6823,6 +6836,7 @@ 'PhabricatorDestructibleInterface', 'PhabricatorApplicationTransactionInterface', 'PhabricatorSpacesInterface', + 'PhabricatorConduitResultInterface', ), 'PhabricatorPasteApplication' => 'PhabricatorApplication', 'PhabricatorPasteArchiveController' => 'PhabricatorPasteController', @@ -6965,6 +6979,7 @@ 'PhabricatorPolicyQuery' => 'PhabricatorCursorPagedPolicyAwareQuery', 'PhabricatorPolicyRequestExceptionHandler' => 'PhabricatorRequestExceptionHandler', 'PhabricatorPolicyRule' => 'Phobject', + 'PhabricatorPolicySearchEngineExtension' => 'PhabricatorSearchEngineExtension', 'PhabricatorPolicyTestCase' => 'PhabricatorTestCase', 'PhabricatorPolicyTestObject' => array( 'Phobject', @@ -7265,6 +7280,9 @@ 'PhabricatorSearchDocumentTypeDatasource' => 'PhabricatorTypeaheadDatasource', 'PhabricatorSearchEditController' => 'PhabricatorSearchBaseController', 'PhabricatorSearchEngine' => 'Phobject', + 'PhabricatorSearchEngineAPIMethod' => 'ConduitAPIMethod', + 'PhabricatorSearchEngineExtension' => 'Phobject', + 'PhabricatorSearchEngineExtensionModule' => 'PhabricatorConfigModule', 'PhabricatorSearchEngineTestCase' => 'PhabricatorTestCase', 'PhabricatorSearchField' => 'Phobject', 'PhabricatorSearchHovercardController' => 'PhabricatorSearchBaseController', @@ -7367,6 +7385,7 @@ 'PhabricatorSpacesNoAccessController' => 'PhabricatorSpacesController', 'PhabricatorSpacesRemarkupRule' => 'PhabricatorObjectRemarkupRule', 'PhabricatorSpacesSchemaSpec' => 'PhabricatorConfigSchemaSpec', + 'PhabricatorSpacesSearchEngineExtension' => 'PhabricatorSearchEngineExtension', 'PhabricatorSpacesSearchField' => 'PhabricatorSearchTokenizerField', 'PhabricatorSpacesTestCase' => 'PhabricatorTestCase', 'PhabricatorSpacesViewController' => 'PhabricatorSpacesController', diff --git a/src/applications/conduit/interface/PhabricatorConduitResultInterface.php b/src/applications/conduit/interface/PhabricatorConduitResultInterface.php new file mode 100644 --- /dev/null +++ b/src/applications/conduit/interface/PhabricatorConduitResultInterface.php @@ -0,0 +1,31 @@ + array( + 'type' => 'string', + 'description' => pht('The name of the object.'), + ), + ); + } + + public function getFieldValuesForConduit() { + return array( + 'name' => $this->getName(), + ); + } + +*/ diff --git a/src/applications/conduit/query/ConduitResultSearchEngineExtension.php b/src/applications/conduit/query/ConduitResultSearchEngineExtension.php new file mode 100644 --- /dev/null +++ b/src/applications/conduit/query/ConduitResultSearchEngineExtension.php @@ -0,0 +1,28 @@ +getFieldSpecificationsForConduit(); + } + + public function getFieldValuesForConduit($object) { + return $object->getFieldValuesForConduit(); + } + +} diff --git a/src/applications/paste/conduit/PasteSearchConduitAPIMethod.php b/src/applications/paste/conduit/PasteSearchConduitAPIMethod.php new file mode 100644 --- /dev/null +++ b/src/applications/paste/conduit/PasteSearchConduitAPIMethod.php @@ -0,0 +1,18 @@ +spacePHID; } + +/* -( PhabricatorConduitResultInterface )---------------------------------- */ + + + public function getFieldSpecificationsForConduit() { + return array( + 'title' => array( + 'type' => 'string', + 'description' => pht('The name of the object.'), + ), + 'authorPHID' => array( + 'type' => 'phid', + 'description' => pht('User PHID of the author.'), + ), + 'language' => array( + 'type' => 'string?', + 'description' => pht('Language to use for syntax highlighting.'), + ), + 'status' => array( + 'type' => 'string', + 'description' => pht('Active or archived status of the paste.'), + ), + ); + } + + public function getFieldValuesForConduit() { + return array( + 'title' => $this->getTitle(), + 'authorPHID' => $this->getAuthorPHID(), + 'language' => nonempty($this->getLanguage(), null), + 'status' => $this->getStatus(), + ); + } + } diff --git a/src/applications/policy/engineextension/PhabricatorPolicySearchEngineExtension.php b/src/applications/policy/engineextension/PhabricatorPolicySearchEngineExtension.php new file mode 100644 --- /dev/null +++ b/src/applications/policy/engineextension/PhabricatorPolicySearchEngineExtension.php @@ -0,0 +1,43 @@ + array( + 'type' => 'map', + 'description' => pht( + 'Map of capabilities to current policies.'), + ), + ); + } + + public function getFieldValuesForConduit($object) { + $capabilities = $object->getCapabilities(); + + $map = array(); + foreach ($capabilities as $capability) { + $map[$capability] = $object->getPolicy($capability); + } + + return array( + 'policy' => $map, + ); + } + +} diff --git a/src/applications/search/engine/PhabricatorApplicationSearchEngine.php b/src/applications/search/engine/PhabricatorApplicationSearchEngine.php --- a/src/applications/search/engine/PhabricatorApplicationSearchEngine.php +++ b/src/applications/search/engine/PhabricatorApplicationSearchEngine.php @@ -1172,4 +1172,197 @@ return $fields; } + public function getSearchFieldsForConduit() { + $fields = $this->buildSearchFields(); + return $fields; + } + + public function buildConduitResponse(ConduitAPIRequest $request) { + $viewer = $this->requireViewer(); + $fields = $this->buildSearchFields(); + + $query_key = $request->getValue('queryKey'); + if (!strlen($query_key)) { + $saved_query = new PhabricatorSavedQuery(); + } else if ($this->isBuiltinQuery($query_key)) { + $saved_query = $this->buildSavedQueryFromBuiltin($query_key); + } else { + $saved_query = id(new PhabricatorSavedQueryQuery()) + ->setViewer($viewer) + ->withQueryKeys(array($query_key)) + ->executeOne(); + if (!$saved_query) { + throw new Exception( + pht( + 'Query key "%s" does not correspond to a valid query.', + $query_key)); + } + } + + foreach ($fields as $field) { + $field->setViewer($viewer); + } + + $constraints = $request->getValue('constraints', array()); + + foreach ($fields as $field) { + if (!$field->getValueExistsInConduitRequest($constraints)) { + continue; + } + + $value = $field->readValueFromConduitRequest($constraints); + $saved_query->setParameter($field->getKey(), $value); + } + + $this->saveQuery($saved_query); + + + $query = $this->buildQueryFromSavedQuery($saved_query); + $pager = $this->newPagerForSavedQuery($saved_query); + + $this->setQueryOrderForConduit($query, $request); + $this->setPagerLimitForConduit($pager, $request); + $this->setPagerOffsetsForConduit($pager, $request); + + $objects = $this->executeQuery($query, $pager); + + $data = array(); + if ($objects) { + $field_extensions = $this->getConduitFieldExtensions(); + + foreach ($objects as $object) { + $data[] = $this->getObjectWireFormatForConduit( + $object, + $field_extensions); + } + } + + return array( + 'data' => $data, + 'query' => array( + 'queryKey' => $saved_query->getQueryKey(), + ), + 'cursor' => array( + 'limit' => $pager->getPageSize(), + 'after' => $pager->getNextPageID(), + 'before' => $pager->getPrevPageID(), + 'order' => $request->getValue('order'), + ), + ); + } + + public function getAllConduitFieldSpecifications() { + $extensions = $this->getConduitFieldExtensions(); + $object = $this->newQuery()->newResultObject(); + + $specifications = array(); + foreach ($extensions as $extension) { + $specifications += $extension->getFieldSpecificationsForConduit($object); + } + + return $specifications; + } + + private function getConduitFieldExtensions() { + $extensions = PhabricatorSearchEngineExtension::getAllEnabledExtensions(); + $object = $this->newQuery()->newResultObject(); + + $field_extensions = array(); + foreach ($extensions as $key => $extension) { + if ($extension->getFieldSpecificationsForConduit($object)) { + $field_extensions[$key] = $extension; + } + } + + return $field_extensions; + } + + private function setQueryOrderForConduit($query, ConduitAPIRequest $request) { + $order = $request->getValue('order'); + if ($order === null) { + return; + } + + if (is_scalar($order)) { + $query->setOrder($order); + } else { + $query->setOrderVector($order); + } + } + + private function setPagerLimitForConduit($pager, ConduitAPIRequest $request) { + $limit = $request->getValue('limit'); + + // If there's no limit specified and the query uses a weird huge page + // size, just leave it at the default gigantic page size. Otherwise, + // make sure it's between 1 and 100, inclusive. + + if ($limit === null) { + if ($pager->getPageSize() >= 0xFFFF) { + return; + } else { + $limit = 100; + } + } + + if ($limit > 100) { + throw new Exception( + pht( + 'Maximum page size for Conduit API method calls is 100, but '. + 'this call specified %s.', + $limit)); + } + + if ($limit < 1) { + throw new Exception( + pht( + 'Minimum page size for API searches is 1, but this call '. + 'specified %s.', + $limit)); + } + + $pager->setPageSize($limit); + } + + private function setPagerOffsetsForConduit( + $pager, + ConduitAPIRequest $request) { + $before_id = $request->getValue('before'); + if ($before_id !== null) { + $pager->setBeforeID($before_id); + } + + $after_id = $request->getValue('after'); + if ($after_id !== null) { + $pager->setAfterID($after_id); + } + } + + protected function getObjectWireFormatForConduit( + $object, + array $field_extensions) { + $phid = $object->getPHID(); + + return array( + 'id' => (int)$object->getID(), + 'type' => phid_get_type($phid), + 'phid' => $phid, + 'fields' => $this->getObjectWireFieldsForConduit( + $object, + $field_extensions), + ); + } + + protected function getObjectWireFieldsForConduit( + $object, + array $field_extensions) { + + $fields = array(); + foreach ($field_extensions as $extension) { + $fields += $extension->getFieldValuesForConduit($object); + } + + return $fields; + } + } diff --git a/src/applications/search/engine/PhabricatorSearchEngineAPIMethod.php b/src/applications/search/engine/PhabricatorSearchEngineAPIMethod.php new file mode 100644 --- /dev/null +++ b/src/applications/search/engine/PhabricatorSearchEngineAPIMethod.php @@ -0,0 +1,384 @@ +newSearchEngine(); + $class = $engine->getApplicationClassName(); + return PhabricatorApplication::getByClass($class); + } + + public function getMethodStatus() { + return self::METHOD_STATUS_UNSTABLE; + } + + public function getMethodStatusDescription() { + return pht('ApplicationSearch methods are highly unstable.'); + } + + final protected function defineParamTypes() { + return array( + 'queryKey' => 'optional string', + 'constraints' => 'optional map', + 'order' => 'optional order', + ) + $this->getPagerParamTypes(); + } + + final protected function defineReturnType() { + return 'map'; + } + + final protected function execute(ConduitAPIRequest $request) { + $engine = $this->newSearchEngine() + ->setViewer($request->getUser()); + + return $engine->buildConduitResponse($request); + } + + final public function getMethodDescription() { + // TODO: We don't currently have a real viewer in this method. + $viewer = PhabricatorUser::getOmnipotentUser(); + + $engine = $this->newSearchEngine() + ->setViewer($viewer); + + $query = $engine->newQuery(); + + $out = array(); + + $out[] = pht(<<loadAllNamedQueries(); + + $table = array(); + $table[] = "| {$head_querykey} | {$head_name} | {$head_builtin} |"; + $table[] = '|------------------|--------------|-----------------|'; + foreach ($named_queries as $named_query) { + $key = $named_query->getQueryKey(); + $name = $named_query->getQueryName(); + $builtin = $named_query->getIsBuiltin() + ? pht('Builtin') + : pht('Custom'); + + $table[] = "| `{$key}` | {$name} | {$builtin} |"; + } + $table = implode("\n", $table); + $out[] = $table; + + $out[] = pht(<<getSearchFieldsForConduit(); + + $table = array(); + $table[] = "| {$head_key} | {$head_label} | {$head_type} | {$head_desc} |"; + $table[] = '|-------------|---------------|--------------|--------------|'; + foreach ($fields as $field) { + $key = $field->getKey(); + $label = $field->getLabel(); + + // TODO: Support generating and surfacing this information. + $type = pht('TODO'); + $description = pht('TODO'); + + $table[] = "| `{$key}` | **{$label}** | `{$type}` | {$description}"; + } + $table = implode("\n", $table); + $out[] = $table; + + + $out[] = pht(<<getBuiltinOrders(); + + $table = array(); + $table[] = "| {$head_builtin} | {$head_description} | {$head_columns} |"; + $table[] = '|-----------------|---------------------|-----------------|'; + foreach ($orders as $key => $order) { + $name = $order['name']; + $columns = implode(', ', $order['vector']); + $table[] = "| `{$key}` | {$name} | {$columns} |"; + } + $table = implode("\n", $table); + $out[] = $table; + + $out[] = pht(<<getOrderableColumns(); + + $table = array(); + $table[] = "| {$head_column} | {$head_unique} |"; + $table[] = '|----------------|----------------|'; + foreach ($columns as $key => $column) { + $unique = idx($column, 'unique') + ? pht('Yes') + : pht('No'); + + $table[] = "| `{$key}` | {$unique} |"; + } + $table = implode("\n", $table); + $out[] = $table; + + + $out[] = pht(<<getAllConduitFieldSpecifications(); + + $table = array(); + $table[] = "| {$head_key} | {$head_type} | {$head_description} |"; + $table[] = '|-------------|--------------|---------------------|'; + foreach ($specs as $key => $spec) { + $type = idx($spec, 'type'); + $description = idx($spec, 'description'); + $table[] = "| `{$key}` | `{$type}` | {$description} |"; + } + $table = implode("\n", $table); + $out[] = $table; + + $out[] = pht(<<getConfigOption(LiskDAO::CONFIG_TIMESTAMPS)) { + return false; + } + + return true; + } + + public function getFieldSpecificationsForConduit($object) { + return array( + 'dateCreated' => array( + 'type' => 'int', + 'description' => pht( + 'Epoch timestamp when the object was created.'), + ), + 'dateModified' => array( + 'type' => 'int', + 'description' => pht( + 'Epoch timestamp when the object was last updated.'), + ), + ); + } + + public function getFieldValuesForConduit($object) { + return array( + 'dateCreated' => (int)$object->getDateCreated(), + 'dateModified' => (int)$object->getDateModified(), + ); + } + +} diff --git a/src/applications/search/engineextension/PhabricatorSearchEngineExtension.php b/src/applications/search/engineextension/PhabricatorSearchEngineExtension.php new file mode 100644 --- /dev/null +++ b/src/applications/search/engineextension/PhabricatorSearchEngineExtension.php @@ -0,0 +1,51 @@ +getPhobjectClassConstant('EXTENSIONKEY'); + } + + final public function setViewer($viewer) { + $this->viewer = $viewer; + return $this; + } + + final public function getViewer() { + return $this->viewer; + } + + abstract public function isExtensionEnabled(); + abstract public function getExtensionName(); + abstract public function supportsObject($object); + + public function getFieldSpecificationsForConduit($object) { + return array(); + } + + public function getFieldValuesForConduit($object) { + return array(); + } + + final public static function getAllExtensions() { + return id(new PhutilClassMapQuery()) + ->setAncestorClass(__CLASS__) + ->setUniqueMethod('getExtensionKey') + ->execute(); + } + + final public static function getAllEnabledExtensions() { + $extensions = self::getAllExtensions(); + + foreach ($extensions as $key => $extension) { + if (!$extension->isExtensionEnabled()) { + unset($extensions[$key]); + } + } + + return $extensions; + } + +} diff --git a/src/applications/search/engineextension/PhabricatorSearchEngineExtensionModule.php b/src/applications/search/engineextension/PhabricatorSearchEngineExtensionModule.php new file mode 100644 --- /dev/null +++ b/src/applications/search/engineextension/PhabricatorSearchEngineExtensionModule.php @@ -0,0 +1,52 @@ +getViewer(); + + $extensions = PhabricatorSearchEngineExtension::getAllExtensions(); + + $rows = array(); + foreach ($extensions as $extension) { + $rows[] = array( + $extension->getExtensionKey(), + get_class($extension), + $extension->getExtensionName(), + $extension->isExtensionEnabled() + ? pht('Yes') + : pht('No'), + ); + } + + $table = id(new AphrontTableView($rows)) + ->setHeaders( + array( + pht('Key'), + pht('Class'), + pht('Name'), + pht('Enabled'), + )) + ->setColumnClasses( + array( + null, + null, + 'wide pri', + null, + )); + + return id(new PHUIObjectBoxView()) + ->setHeaderText(pht('SearchEngine Extensions')) + ->setTable($table); + } + +} diff --git a/src/applications/search/field/PhabricatorSearchField.php b/src/applications/search/field/PhabricatorSearchField.php --- a/src/applications/search/field/PhabricatorSearchField.php +++ b/src/applications/search/field/PhabricatorSearchField.php @@ -205,6 +205,14 @@ return $value; } + public function getValueExistsInConduitRequest(array $constraints) { + return array_key_exists($this->getKey(), $constraints); + } + + public function readValueFromConduitRequest(array $constraints) { + return idx($constraints, $this->getKey()); + } + /* -( Rendering Controls )------------------------------------------------- */ diff --git a/src/applications/spaces/engineextension/PhabricatorSpacesSearchEngineExtension.php b/src/applications/spaces/engineextension/PhabricatorSpacesSearchEngineExtension.php new file mode 100644 --- /dev/null +++ b/src/applications/spaces/engineextension/PhabricatorSpacesSearchEngineExtension.php @@ -0,0 +1,37 @@ + array( + 'type' => 'phid?', + 'description' => pht( + 'PHID of the policy space this object is part of.'), + ), + ); + } + + public function getFieldValuesForConduit($object) { + return array( + 'spacePHID' => $object->getSpacePHID(), + ); + } + +}