2012-01-18 01:29:35 +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
|
|
|
abstract class ProjectConduitAPIMethod extends ConduitAPIMethod {
|
2012-01-18 01:29:35 +01:00
|
|
|
|
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 public function getApplication() {
|
2014-07-23 02:03:09 +02:00
|
|
|
return PhabricatorApplication::getByClass('PhabricatorProjectApplication');
|
2013-03-13 15:09:05 +01:00
|
|
|
}
|
|
|
|
|
2012-01-18 01:29:35 +01:00
|
|
|
protected function buildProjectInfoDictionary(PhabricatorProject $project) {
|
|
|
|
$results = $this->buildProjectInfoDictionaries(array($project));
|
|
|
|
return idx($results, $project->getPHID());
|
|
|
|
}
|
|
|
|
|
|
|
|
protected function buildProjectInfoDictionaries(array $projects) {
|
2012-04-03 21:10:45 +02:00
|
|
|
assert_instances_of($projects, 'PhabricatorProject');
|
2012-01-18 01:29:35 +01:00
|
|
|
if (!$projects) {
|
|
|
|
return array();
|
|
|
|
}
|
|
|
|
|
|
|
|
$result = array();
|
|
|
|
foreach ($projects as $project) {
|
|
|
|
|
2012-08-07 20:55:00 +02:00
|
|
|
$member_phids = $project->getMemberPHIDs();
|
2012-01-18 01:29:35 +01:00
|
|
|
$member_phids = array_values($member_phids);
|
|
|
|
|
Include project slugs in the results of a `project.query` Conduit call.
Summary: Ref T4418. This feature will be used by D9457 to determine whether the specified slugs exist.
Test Plan:
Made a conduit call with `arc`:
```
> echo '{"slugs": ["foo"]}' | arc --conduit-uri='http://phabricator.joshuaspence.com' call-conduit project.query
Waiting for JSON parameters on stdin...
{"error":null,"errorMessage":null,"response":{"data":{"PHID-PROJ-ttomlhslujpx5sdpbu2c":{"id":"1","phid":"PHID-PROJ-ttomlhslujpx5sdpbu2c","name":"Foo","members":["PHID-USER-cb5af6p4oepy5tlgqypi"],"slugs":["foo","bar"],"dateCreated":"1402422720","dateModified":"1402422728"}},"slugMap":{"foo":"PHID-PROJ-ttomlhslujpx5sdpbu2c"},"cursor":{"limit":100,"after":null,"before":null}}}
```
Reviewers: #blessed_reviewers, epriestley
Reviewed By: #blessed_reviewers, epriestley
Subscribers: epriestley, Korvin
Maniphest Tasks: T4418
Differential Revision: https://secure.phabricator.com/D9619
2014-06-24 07:09:19 +02:00
|
|
|
$project_slugs = $project->getSlugs();
|
|
|
|
$project_slugs = array_values(mpull($project_slugs, 'getSlug'));
|
|
|
|
|
2014-11-09 20:37:04 +01:00
|
|
|
$project_icon = PhabricatorProjectIcon::getAPIName($project->getIcon());
|
|
|
|
|
2012-01-18 01:29:35 +01:00
|
|
|
$result[$project->getPHID()] = array(
|
2014-11-09 20:37:04 +01:00
|
|
|
'id' => $project->getID(),
|
|
|
|
'phid' => $project->getPHID(),
|
|
|
|
'name' => $project->getName(),
|
|
|
|
'profileImagePHID' => $project->getProfileImagePHID(),
|
|
|
|
'icon' => $project_icon,
|
|
|
|
'color' => $project->getColor(),
|
|
|
|
'members' => $member_phids,
|
|
|
|
'slugs' => $project_slugs,
|
|
|
|
'dateCreated' => $project->getDateCreated(),
|
|
|
|
'dateModified' => $project->getDateModified(),
|
2012-01-18 01:29:35 +01:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
return $result;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|