mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-19 13:22:42 +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:
parent
663dce5029
commit
99ade500bc
5 changed files with 69 additions and 3 deletions
|
@ -233,6 +233,7 @@ phutil_register_library_map(array(
|
||||||
'ConduitException' => 'applications/conduit/protocol/exception/ConduitException.php',
|
'ConduitException' => 'applications/conduit/protocol/exception/ConduitException.php',
|
||||||
'ConduitGetCapabilitiesConduitAPIMethod' => 'applications/conduit/method/ConduitGetCapabilitiesConduitAPIMethod.php',
|
'ConduitGetCapabilitiesConduitAPIMethod' => 'applications/conduit/method/ConduitGetCapabilitiesConduitAPIMethod.php',
|
||||||
'ConduitGetCertificateConduitAPIMethod' => 'applications/conduit/method/ConduitGetCertificateConduitAPIMethod.php',
|
'ConduitGetCertificateConduitAPIMethod' => 'applications/conduit/method/ConduitGetCertificateConduitAPIMethod.php',
|
||||||
|
'ConduitIntListParameterType' => 'applications/conduit/parametertype/ConduitIntListParameterType.php',
|
||||||
'ConduitIntParameterType' => 'applications/conduit/parametertype/ConduitIntParameterType.php',
|
'ConduitIntParameterType' => 'applications/conduit/parametertype/ConduitIntParameterType.php',
|
||||||
'ConduitListParameterType' => 'applications/conduit/parametertype/ConduitListParameterType.php',
|
'ConduitListParameterType' => 'applications/conduit/parametertype/ConduitListParameterType.php',
|
||||||
'ConduitLogGarbageCollector' => 'applications/conduit/garbagecollector/ConduitLogGarbageCollector.php',
|
'ConduitLogGarbageCollector' => 'applications/conduit/garbagecollector/ConduitLogGarbageCollector.php',
|
||||||
|
@ -4085,6 +4086,7 @@ phutil_register_library_map(array(
|
||||||
'ConduitException' => 'Exception',
|
'ConduitException' => 'Exception',
|
||||||
'ConduitGetCapabilitiesConduitAPIMethod' => 'ConduitAPIMethod',
|
'ConduitGetCapabilitiesConduitAPIMethod' => 'ConduitAPIMethod',
|
||||||
'ConduitGetCertificateConduitAPIMethod' => 'ConduitAPIMethod',
|
'ConduitGetCertificateConduitAPIMethod' => 'ConduitAPIMethod',
|
||||||
|
'ConduitIntListParameterType' => 'ConduitListParameterType',
|
||||||
'ConduitIntParameterType' => 'ConduitListParameterType',
|
'ConduitIntParameterType' => 'ConduitListParameterType',
|
||||||
'ConduitListParameterType' => 'ConduitParameterType',
|
'ConduitListParameterType' => 'ConduitParameterType',
|
||||||
'ConduitLogGarbageCollector' => 'PhabricatorGarbageCollector',
|
'ConduitLogGarbageCollector' => 'PhabricatorGarbageCollector',
|
||||||
|
|
|
@ -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]',
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -48,20 +48,30 @@ final class ManiphestTaskSearchEngine
|
||||||
id(new PhabricatorOwnersSearchField())
|
id(new PhabricatorOwnersSearchField())
|
||||||
->setLabel(pht('Assigned To'))
|
->setLabel(pht('Assigned To'))
|
||||||
->setKey('assignedPHIDs')
|
->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())
|
id(new PhabricatorUsersSearchField())
|
||||||
->setLabel(pht('Authors'))
|
->setLabel(pht('Authors'))
|
||||||
->setKey('authorPHIDs')
|
->setKey('authorPHIDs')
|
||||||
->setAliases(array('author', 'authors')),
|
->setAliases(array('author', 'authors'))
|
||||||
|
->setDescription(
|
||||||
|
pht('Search for tasks with given authors.')),
|
||||||
id(new PhabricatorSearchDatasourceField())
|
id(new PhabricatorSearchDatasourceField())
|
||||||
->setLabel(pht('Statuses'))
|
->setLabel(pht('Statuses'))
|
||||||
->setKey('statuses')
|
->setKey('statuses')
|
||||||
->setAliases(array('status'))
|
->setAliases(array('status'))
|
||||||
|
->setDescription(
|
||||||
|
pht('Search for tasks with given statuses.'))
|
||||||
->setDatasource(new ManiphestTaskStatusFunctionDatasource()),
|
->setDatasource(new ManiphestTaskStatusFunctionDatasource()),
|
||||||
id(new PhabricatorSearchDatasourceField())
|
id(new PhabricatorSearchDatasourceField())
|
||||||
->setLabel(pht('Priorities'))
|
->setLabel(pht('Priorities'))
|
||||||
->setKey('priorities')
|
->setKey('priorities')
|
||||||
->setAliases(array('priority'))
|
->setAliases(array('priority'))
|
||||||
|
->setDescription(
|
||||||
|
pht('Search for tasks with given priorities.'))
|
||||||
|
->setConduitParameterType(new ConduitIntListParameterType())
|
||||||
->setDatasource(new ManiphestTaskPriorityDatasource()),
|
->setDatasource(new ManiphestTaskPriorityDatasource()),
|
||||||
id(new PhabricatorSearchTextField())
|
id(new PhabricatorSearchTextField())
|
||||||
->setLabel(pht('Contains Words'))
|
->setLabel(pht('Contains Words'))
|
||||||
|
|
|
@ -15,4 +15,8 @@ final class PhabricatorOwnersSearchField
|
||||||
return new PhabricatorPeopleOwnerDatasource();
|
return new PhabricatorPeopleOwnerDatasource();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function newConduitParameterType() {
|
||||||
|
return new ConduitUserListParameterType();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,6 +4,7 @@ final class PhabricatorSearchDatasourceField
|
||||||
extends PhabricatorSearchTokenizerField {
|
extends PhabricatorSearchTokenizerField {
|
||||||
|
|
||||||
private $datasource;
|
private $datasource;
|
||||||
|
private $conduitParameterType;
|
||||||
|
|
||||||
protected function newDatasource() {
|
protected function newDatasource() {
|
||||||
return id(clone $this->datasource);
|
return id(clone $this->datasource);
|
||||||
|
@ -14,8 +15,17 @@ final class PhabricatorSearchDatasourceField
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function setConduitParameterType(ConduitParameterType $type) {
|
||||||
|
$this->conduitParameterType = $type;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
protected function newConduitParameterType() {
|
protected function newConduitParameterType() {
|
||||||
return new ConduitStringListParameterType();
|
if (!$this->conduitParameterType) {
|
||||||
|
return new ConduitStringListParameterType();
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->conduitParameterType;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue