1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-24 15:52:41 +01:00
phorge-phorge/src/applications/project/conduit/ProjectConduitAPIMethod.php
Merlijn van Deen ce55bb1d96 Add icon, color and profile image to project.query
Summary:
 - The icon CSS tag is transformed through the new function
   PhabricatorProjectIcon::getAPIName($key), which returns
   a name without fa-.

 - Color is a trivial lookup
 - Profile image returns the PHID or null if not available

Test Plan:
 - Create two projects, with different icon and color,
   one with and one without profile image.
 - Request information on both using project.query
Then:
 [ ] Confirm icon and colors are correct for both projects
 [ ] Confirm image PHID is correct
 [ ] Confirm image PHID is null for the project without image

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: yuvipanda, Korvin, legoktm, epriestley

Maniphest Tasks: T6501

Differential Revision: https://secure.phabricator.com/D10823
2014-11-09 11:37:23 -08:00

48 lines
1.5 KiB
PHP

<?php
abstract class ProjectConduitAPIMethod extends ConduitAPIMethod {
final public function getApplication() {
return PhabricatorApplication::getByClass('PhabricatorProjectApplication');
}
protected function buildProjectInfoDictionary(PhabricatorProject $project) {
$results = $this->buildProjectInfoDictionaries(array($project));
return idx($results, $project->getPHID());
}
protected function buildProjectInfoDictionaries(array $projects) {
assert_instances_of($projects, 'PhabricatorProject');
if (!$projects) {
return array();
}
$result = array();
foreach ($projects as $project) {
$member_phids = $project->getMemberPHIDs();
$member_phids = array_values($member_phids);
$project_slugs = $project->getSlugs();
$project_slugs = array_values(mpull($project_slugs, 'getSlug'));
$project_icon = PhabricatorProjectIcon::getAPIName($project->getIcon());
$result[$project->getPHID()] = array(
'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(),
);
}
return $result;
}
}