1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-19 05:12:41 +01:00

Flesh out Conduit parmeter types for maniphest.search

Summary: Ref T9964. I left a couple of these unsupported for now since they're weird in some way.

Test Plan: {F1024031}

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T9964

Differential Revision: https://secure.phabricator.com/D14767
This commit is contained in:
epriestley 2015-12-13 07:43:02 -08:00
parent 663dce5029
commit 99ade500bc
5 changed files with 69 additions and 3 deletions

View file

@ -233,6 +233,7 @@ phutil_register_library_map(array(
'ConduitException' => 'applications/conduit/protocol/exception/ConduitException.php',
'ConduitGetCapabilitiesConduitAPIMethod' => 'applications/conduit/method/ConduitGetCapabilitiesConduitAPIMethod.php',
'ConduitGetCertificateConduitAPIMethod' => 'applications/conduit/method/ConduitGetCertificateConduitAPIMethod.php',
'ConduitIntListParameterType' => 'applications/conduit/parametertype/ConduitIntListParameterType.php',
'ConduitIntParameterType' => 'applications/conduit/parametertype/ConduitIntParameterType.php',
'ConduitListParameterType' => 'applications/conduit/parametertype/ConduitListParameterType.php',
'ConduitLogGarbageCollector' => 'applications/conduit/garbagecollector/ConduitLogGarbageCollector.php',
@ -4085,6 +4086,7 @@ phutil_register_library_map(array(
'ConduitException' => 'Exception',
'ConduitGetCapabilitiesConduitAPIMethod' => 'ConduitAPIMethod',
'ConduitGetCertificateConduitAPIMethod' => 'ConduitAPIMethod',
'ConduitIntListParameterType' => 'ConduitListParameterType',
'ConduitIntParameterType' => 'ConduitListParameterType',
'ConduitListParameterType' => 'ConduitParameterType',
'ConduitLogGarbageCollector' => 'PhabricatorGarbageCollector',

View file

@ -0,0 +1,40 @@
<?php
final class ConduitIntListParameterType
extends ConduitListParameterType {
protected function getParameterValue(array $request, $key) {
$list = parent::getParameterValue($request, $key);
foreach ($list as $idx => $item) {
if (!is_int($item)) {
$this->raiseValidationException(
$request,
$key,
pht(
'Expected a list of integers, but item with index "%s" is '.
'not an integer.',
$idx));
}
}
return $this->validateIntList($request, $key, $list);
}
protected function getParameterTypeName() {
return 'list<int>';
}
protected function getParameterFormatDescriptions() {
return array(
pht('List of integers.'),
);
}
protected function getParameterExamples() {
return array(
'[123, 0, -456]',
);
}
}

View file

@ -48,20 +48,30 @@ final class ManiphestTaskSearchEngine
id(new PhabricatorOwnersSearchField())
->setLabel(pht('Assigned To'))
->setKey('assignedPHIDs')
->setAliases(array('assigned')),
->setConduitKey('assigned')
->setAliases(array('assigned'))
->setDescription(
pht('Search for tasks owned by a user from a list.')),
id(new PhabricatorUsersSearchField())
->setLabel(pht('Authors'))
->setKey('authorPHIDs')
->setAliases(array('author', 'authors')),
->setAliases(array('author', 'authors'))
->setDescription(
pht('Search for tasks with given authors.')),
id(new PhabricatorSearchDatasourceField())
->setLabel(pht('Statuses'))
->setKey('statuses')
->setAliases(array('status'))
->setDescription(
pht('Search for tasks with given statuses.'))
->setDatasource(new ManiphestTaskStatusFunctionDatasource()),
id(new PhabricatorSearchDatasourceField())
->setLabel(pht('Priorities'))
->setKey('priorities')
->setAliases(array('priority'))
->setDescription(
pht('Search for tasks with given priorities.'))
->setConduitParameterType(new ConduitIntListParameterType())
->setDatasource(new ManiphestTaskPriorityDatasource()),
id(new PhabricatorSearchTextField())
->setLabel(pht('Contains Words'))

View file

@ -15,4 +15,8 @@ final class PhabricatorOwnersSearchField
return new PhabricatorPeopleOwnerDatasource();
}
protected function newConduitParameterType() {
return new ConduitUserListParameterType();
}
}

View file

@ -4,6 +4,7 @@ final class PhabricatorSearchDatasourceField
extends PhabricatorSearchTokenizerField {
private $datasource;
private $conduitParameterType;
protected function newDatasource() {
return id(clone $this->datasource);
@ -14,8 +15,17 @@ final class PhabricatorSearchDatasourceField
return $this;
}
public function setConduitParameterType(ConduitParameterType $type) {
$this->conduitParameterType = $type;
return $this;
}
protected function newConduitParameterType() {
return new ConduitStringListParameterType();
if (!$this->conduitParameterType) {
return new ConduitStringListParameterType();
}
return $this->conduitParameterType;
}
}