2011-02-06 23:43:06 +01:00
|
|
|
<?php
|
|
|
|
|
Rename Conduit classes
Summary: Ref T5655. Rename Conduit classes and provide a `getAPIMethodName` method to declare the API method.
Test Plan:
```
> echo '{}' | arc --conduit-uri='http://phabricator.joshuaspence.com' call-conduit user.whoami
Waiting for JSON parameters on stdin...
{"error":null,"errorMessage":null,"response":{"phid":"PHID-USER-lioqffnwn6y475mu5ndb","userName":"josh","realName":"Joshua Spence","image":"http:\/\/phabricator.joshuaspence.com\/res\/1404425321T\/phabricator\/3eb28cd9\/rsrc\/image\/avatar.png","uri":"http:\/\/phabricator.joshuaspence.com\/p\/josh\/","roles":["admin","verified","approved","activated"]}}
```
Reviewers: epriestley, #blessed_reviewers
Reviewed By: epriestley, #blessed_reviewers
Subscribers: epriestley, Korvin, hach-que
Maniphest Tasks: T5655
Differential Revision: https://secure.phabricator.com/D9991
2014-07-25 02:54:15 +02:00
|
|
|
final class DifferentialFindConduitAPIMethod
|
|
|
|
extends DifferentialConduitAPIMethod {
|
|
|
|
|
|
|
|
public function getAPIMethodName() {
|
|
|
|
return 'differential.find';
|
|
|
|
}
|
2011-02-06 23:43:06 +01:00
|
|
|
|
2012-04-18 23:25:27 +02:00
|
|
|
public function getMethodStatus() {
|
|
|
|
return self::METHOD_STATUS_DEPRECATED;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getMethodStatusDescription() {
|
|
|
|
return "Replaced by 'differential.query'.";
|
|
|
|
}
|
|
|
|
|
2011-02-06 23:43:06 +01:00
|
|
|
public function getMethodDescription() {
|
2014-06-09 20:36:49 +02:00
|
|
|
return 'Query Differential revisions which match certain criteria.';
|
2011-02-06 23:43:06 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public function defineParamTypes() {
|
|
|
|
$types = array(
|
2013-07-01 21:38:08 +02:00
|
|
|
'open',
|
|
|
|
'committable',
|
|
|
|
'revision-ids',
|
|
|
|
'phids',
|
2011-02-06 23:43:06 +01:00
|
|
|
);
|
|
|
|
|
|
|
|
return array(
|
2014-05-15 06:59:03 +02:00
|
|
|
'query' => 'required '.$this->formatStringConstants($types),
|
2011-04-22 03:47:04 +02:00
|
|
|
'guids' => 'required nonempty list<guids>',
|
2011-02-06 23:43:06 +01:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function defineReturnType() {
|
|
|
|
return 'nonempty list<dict>';
|
|
|
|
}
|
|
|
|
|
|
|
|
public function defineErrorTypes() {
|
|
|
|
return array(
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
protected function execute(ConduitAPIRequest $request) {
|
2013-07-01 21:38:08 +02:00
|
|
|
$type = $request->getValue('query');
|
2011-04-22 03:47:04 +02:00
|
|
|
$guids = $request->getValue('guids');
|
2011-02-06 23:43:06 +01:00
|
|
|
|
2011-04-27 06:59:44 +02:00
|
|
|
$results = array();
|
|
|
|
if (!$guids) {
|
|
|
|
return $results;
|
|
|
|
}
|
|
|
|
|
2013-07-01 21:38:08 +02:00
|
|
|
$query = id(new DifferentialRevisionQuery())
|
|
|
|
->setViewer($request->getUser());
|
|
|
|
|
|
|
|
switch ($type) {
|
|
|
|
case 'open':
|
|
|
|
$query
|
|
|
|
->withStatus(DifferentialRevisionQuery::STATUS_OPEN)
|
|
|
|
->withAuthors($guids);
|
|
|
|
break;
|
|
|
|
case 'committable':
|
|
|
|
$query
|
|
|
|
->withStatus(DifferentialRevisionQuery::STATUS_ACCEPTED)
|
|
|
|
->withAuthors($guids);
|
|
|
|
break;
|
|
|
|
case 'revision-ids':
|
|
|
|
$query
|
|
|
|
->withIDs($guids);
|
|
|
|
break;
|
2013-08-28 22:29:36 +02:00
|
|
|
case 'owned':
|
|
|
|
$query->withAuthors($guids);
|
|
|
|
break;
|
2013-07-01 21:38:08 +02:00
|
|
|
case 'phids':
|
|
|
|
$query
|
|
|
|
->withPHIDs($guids);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
$revisions = $query->execute();
|
2011-02-06 23:43:06 +01:00
|
|
|
|
2011-02-07 20:46:01 +01:00
|
|
|
foreach ($revisions as $revision) {
|
2011-02-06 23:43:06 +01:00
|
|
|
$diff = $revision->loadActiveDiff();
|
2011-02-07 20:46:01 +01:00
|
|
|
if (!$diff) {
|
|
|
|
continue;
|
|
|
|
}
|
2011-05-30 21:04:15 +02:00
|
|
|
$id = $revision->getID();
|
2011-02-06 23:43:06 +01:00
|
|
|
$results[] = array(
|
2011-05-30 21:04:15 +02:00
|
|
|
'id' => $id,
|
2011-04-22 03:47:04 +02:00
|
|
|
'phid' => $revision->getPHID(),
|
2011-02-07 20:46:01 +01:00
|
|
|
'name' => $revision->getTitle(),
|
2011-05-30 21:04:15 +02:00
|
|
|
'uri' => PhabricatorEnv::getProductionURI('/D'.$id),
|
2011-05-10 23:44:40 +02:00
|
|
|
'dateCreated' => $revision->getDateCreated(),
|
|
|
|
'authorPHID' => $revision->getAuthorPHID(),
|
2012-01-10 20:39:11 +01:00
|
|
|
'statusName' =>
|
|
|
|
ArcanistDifferentialRevisionStatus::getNameForRevisionStatus(
|
|
|
|
$revision->getStatus()),
|
2011-02-06 23:43:06 +01:00
|
|
|
'sourcePath' => $diff->getSourcePath(),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
return $results;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|