[ Index ] |
PHP Cross Reference of Phabricator |
[Summary view] [Print] [Text view]
1 <?php 2 3 final class PhabricatorOwnersOwner extends PhabricatorOwnersDAO { 4 5 protected $packageID; 6 7 // this can be a project or a user. We assume that all members of a project 8 // owner also own the package; use the loadAffiliatedUserPHIDs method if 9 // you want to recursively grab all user ids that own a package 10 protected $userPHID; 11 12 public function getConfiguration() { 13 return array( 14 self::CONFIG_TIMESTAMPS => false, 15 self::CONFIG_KEY_SCHEMA => array( 16 'packageID' => array( 17 'columns' => array('packageID', 'userPHID'), 18 'unique' => true, 19 ), 20 'userPHID' => array( 21 'columns' => array('userPHID'), 22 ), 23 ), 24 ) + parent::getConfiguration(); 25 } 26 27 public static function loadAllForPackages(array $packages) { 28 assert_instances_of($packages, 'PhabricatorOwnersPackage'); 29 if (!$packages) { 30 return array(); 31 } 32 return id(new PhabricatorOwnersOwner())->loadAllWhere( 33 'packageID IN (%Ls)', 34 mpull($packages, 'getID')); 35 } 36 37 // Loads all user phids affiliated with a set of packages. This includes both 38 // user owners and all members of any project owners 39 public static function loadAffiliatedUserPHIDs(array $package_ids) { 40 if (!$package_ids) { 41 return array(); 42 } 43 $owners = id(new PhabricatorOwnersOwner())->loadAllWhere( 44 'packageID IN (%Ls)', 45 $package_ids); 46 47 $all_phids = phid_group_by_type(mpull($owners, 'getUserPHID')); 48 49 $user_phids = idx($all_phids, 50 PhabricatorPeopleUserPHIDType::TYPECONST, 51 array()); 52 53 $users_in_project_phids = array(); 54 $project_phids = idx( 55 $all_phids, 56 PhabricatorProjectProjectPHIDType::TYPECONST); 57 if ($project_phids) { 58 $query = id(new PhabricatorEdgeQuery()) 59 ->withSourcePHIDs($project_phids) 60 ->withEdgeTypes(array(PhabricatorEdgeConfig::TYPE_PROJ_MEMBER)); 61 $query->execute(); 62 $users_in_project_phids = $query->getDestinationPHIDs(); 63 } 64 65 return array_unique(array_merge($users_in_project_phids, $user_phids)); 66 } 67 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Sun Nov 30 09:20:46 2014 | Cross-referenced by PHPXref 0.7.1 |