From ce55bb1d9630f35a9ab4dee2dced03536e484efd Mon Sep 17 00:00:00 2001 From: Merlijn van Deen Date: Sun, 9 Nov 2014 11:37:04 -0800 Subject: [PATCH] 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 --- .../conduit/ProjectConduitAPIMethod.php | 19 ++++++++++++------- .../project/icon/PhabricatorProjectIcon.php | 4 ++++ 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/src/applications/project/conduit/ProjectConduitAPIMethod.php b/src/applications/project/conduit/ProjectConduitAPIMethod.php index fc400284f8..419adc2c36 100644 --- a/src/applications/project/conduit/ProjectConduitAPIMethod.php +++ b/src/applications/project/conduit/ProjectConduitAPIMethod.php @@ -26,14 +26,19 @@ abstract class ProjectConduitAPIMethod extends ConduitAPIMethod { $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(), - 'members' => $member_phids, - 'slugs' => $project_slugs, - 'dateCreated' => $project->getDateCreated(), - 'dateModified' => $project->getDateModified(), + '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(), ); } diff --git a/src/applications/project/icon/PhabricatorProjectIcon.php b/src/applications/project/icon/PhabricatorProjectIcon.php index 7ed9d1c535..ae6efa9b6e 100644 --- a/src/applications/project/icon/PhabricatorProjectIcon.php +++ b/src/applications/project/icon/PhabricatorProjectIcon.php @@ -39,6 +39,10 @@ final class PhabricatorProjectIcon extends Phobject { return $map[$key]; } + public static function getAPIName($key) { + return substr($key, 3); + } + public static function renderIconForChooser($icon) { $project_icons = PhabricatorProjectIcon::getIconMap();