2011-09-16 20:42:45 +02: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 ArcanistProjectInfoConduitAPIMethod
|
|
|
|
extends ArcanistConduitAPIMethod {
|
|
|
|
|
|
|
|
public function getAPIMethodName() {
|
|
|
|
return 'arcanist.projectinfo';
|
|
|
|
}
|
2011-09-16 20:42:45 +02:00
|
|
|
|
|
|
|
public function getMethodDescription() {
|
2014-06-09 20:36:49 +02:00
|
|
|
return 'Get information about Arcanist projects.';
|
2011-09-16 20:42:45 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public function defineParamTypes() {
|
|
|
|
return array(
|
|
|
|
'name' => 'required string',
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function defineReturnType() {
|
|
|
|
return 'nonempty dict';
|
|
|
|
}
|
|
|
|
|
|
|
|
public function defineErrorTypes() {
|
|
|
|
return array(
|
|
|
|
'ERR-BAD-ARCANIST-PROJECT' => 'No such project exists.',
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
protected function execute(ConduitAPIRequest $request) {
|
|
|
|
$name = $request->getValue('name');
|
|
|
|
|
|
|
|
$project = id(new PhabricatorRepositoryArcanistProject())->loadOneWhere(
|
|
|
|
'name = %s',
|
|
|
|
$name);
|
|
|
|
|
|
|
|
if (!$project) {
|
|
|
|
throw new ConduitException('ERR-BAD-ARCANIST-PROJECT');
|
|
|
|
}
|
|
|
|
|
2015-02-02 22:58:33 +01:00
|
|
|
$repository = null;
|
|
|
|
if ($project->getRepositoryID()) {
|
|
|
|
$repository = id(new PhabricatorRepositoryQuery())
|
|
|
|
->setViewer($request->getUser())
|
2015-02-02 23:36:57 +01:00
|
|
|
->withIDs(array($project->getRepositoryID()))
|
2015-02-02 22:58:33 +01:00
|
|
|
->executeOne();
|
|
|
|
}
|
2011-09-16 20:42:45 +02:00
|
|
|
|
|
|
|
$repository_phid = null;
|
|
|
|
$tracked = false;
|
2011-11-03 05:36:59 +01:00
|
|
|
$encoding = null;
|
2012-12-11 00:02:36 +01:00
|
|
|
$dictionary = array();
|
2011-09-16 20:42:45 +02:00
|
|
|
if ($repository) {
|
|
|
|
$repository_phid = $repository->getPHID();
|
|
|
|
$tracked = $repository->isTracked();
|
2011-11-03 05:36:59 +01:00
|
|
|
$encoding = $repository->getDetail('encoding');
|
2012-12-11 00:02:36 +01:00
|
|
|
$dictionary = $repository->toDictionary();
|
2011-09-16 20:42:45 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return array(
|
|
|
|
'name' => $project->getName(),
|
|
|
|
'phid' => $project->getPHID(),
|
|
|
|
'repositoryPHID' => $repository_phid,
|
|
|
|
'tracked' => $tracked,
|
2011-11-03 05:36:59 +01:00
|
|
|
'encoding' => $encoding,
|
2012-12-11 00:02:36 +01:00
|
|
|
'repository' => $dictionary,
|
2011-09-16 20:42:45 +02:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|