From 9f12ffbabaa6cbdeb64a5e0c13feec915ee1c91f Mon Sep 17 00:00:00 2001 From: adonohue Date: Wed, 11 May 2011 18:56:48 -0700 Subject: [PATCH] Clean up path.getowners Summary: Change some stuff in path.getowners for clarity Test Plan: Conduit test console Reviewed By: epriestley Reviewers: epriestley, Leon CC: aran, epriestley Differential Revision: 271 --- .../ConduitAPI_path_getowners_Method.php | 36 ++++++++----------- .../method/path/getowners/__init__.php | 1 - 2 files changed, 15 insertions(+), 22 deletions(-) diff --git a/src/applications/conduit/method/path/getowners/ConduitAPI_path_getowners_Method.php b/src/applications/conduit/method/path/getowners/ConduitAPI_path_getowners_Method.php index 50f34cc211..f507ccc474 100644 --- a/src/applications/conduit/method/path/getowners/ConduitAPI_path_getowners_Method.php +++ b/src/applications/conduit/method/path/getowners/ConduitAPI_path_getowners_Method.php @@ -19,7 +19,7 @@ class ConduitAPI_path_getowners_Method extends ConduitAPIMethod { public function getMethodDescription() { - return "Find owners package given its name"; + return "Find the Owners package that contains a given path."; } public function defineParamTypes() { @@ -30,14 +30,18 @@ class ConduitAPI_path_getowners_Method extends ConduitAPIMethod { } public function defineReturnType() { - return 'array of packages containing phid, primary_owner (phid=>username),'. - 'owners(array of phid=>username)'; + return + "array(". + "array(". + "'phid' => phid, ". + "'primaryOwner' => phid, ". + "'owners' => array(phid)))"; } public function defineErrorTypes() { return array( 'ERR_REP_NOT_FOUND' => 'The repository callsign is not recognized', - 'ERR_PATH_NOT_FOUND' => 'The specified path is not known to any package', + 'ERR_PATH_NOT_FOUND' => 'The specified path is not in any package', ); } @@ -56,26 +60,16 @@ class ConduitAPI_path_getowners_Method extends ConduitAPIMethod { throw new ConduitException('ERR_PATH_NOT_FOUND'); } - $owner = new PhabricatorOwnersOwner(); - $user = new PhabricatorUser(); $result = array(); foreach ($packages as $package) { - $p_result = array(); - $p_result['phid'] = $package->getID(); - $primary_owner_phid = $package->getPrimaryOwnerPHID(); - if (!empty($primary_owner_phid)) { - $p_user = $user->loadOneWhere('phid = %s', - $primary_owner_phid); - $p_result['primaryOwner'] = $p_user->getPhid(); - } + $p_owners = + id(new PhabricatorOwnersOwner())->loadAllForPackages(array($package)); - $p_owners = $owner->loadAllForPackages(array($package)); - $p_users = $user->loadAllWhere('phid IN (%Ls)', - mpull($p_owners, 'getUserPHID')); - - $p_result['owners'] = array_values(mpull($p_users, 'getPhid')); - - $result[] = $p_result; + $result[] = array( + 'phid' => $package->getPHID(), + 'primaryOwner' => $package->getPrimaryOwnerPHID(), + 'owners' => array_values(mpull($p_owners, 'getUserPHID')), + ); } return $result; diff --git a/src/applications/conduit/method/path/getowners/__init__.php b/src/applications/conduit/method/path/getowners/__init__.php index 0ca5823ef3..04e759ac75 100644 --- a/src/applications/conduit/method/path/getowners/__init__.php +++ b/src/applications/conduit/method/path/getowners/__init__.php @@ -10,7 +10,6 @@ phutil_require_module('phabricator', 'applications/conduit/method/base'); phutil_require_module('phabricator', 'applications/conduit/protocol/exception'); phutil_require_module('phabricator', 'applications/owners/storage/owner'); phutil_require_module('phabricator', 'applications/owners/storage/package'); -phutil_require_module('phabricator', 'applications/people/storage/user'); phutil_require_module('phabricator', 'applications/repository/storage/repository'); phutil_require_module('phutil', 'utils');