2012-01-18 01:29:35 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
abstract class ConduitAPI_project_Method extends ConduitAPIMethod {
|
|
|
|
|
2013-03-13 15:09:05 +01:00
|
|
|
public function getApplication() {
|
|
|
|
return PhabricatorApplication::getByClass(
|
|
|
|
'PhabricatorApplicationProject');
|
|
|
|
}
|
|
|
|
|
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'));
|
|
|
|
|
2012-01-18 01:29:35 +01:00
|
|
|
$result[$project->getPHID()] = array(
|
|
|
|
'id' => $project->getID(),
|
|
|
|
'phid' => $project->getPHID(),
|
|
|
|
'name' => $project->getName(),
|
|
|
|
'members' => $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
|
|
|
'slugs' => $project_slugs,
|
2012-01-18 01:29:35 +01:00
|
|
|
'dateCreated' => $project->getDateCreated(),
|
|
|
|
'dateModified' => $project->getDateModified(),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
return $result;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|