[ Index ] |
PHP Cross Reference of Phabricator |
[Summary view] [Print] [Text view]
1 <?php 2 3 /** 4 * Expands aggregate mail recipients into their component mailables. For 5 * example, a project currently expands into all of its members. 6 */ 7 final class PhabricatorMetaMTAMemberQuery extends PhabricatorQuery { 8 9 private $phids = array(); 10 private $viewer; 11 12 public function setViewer(PhabricatorUser $viewer) { 13 $this->viewer = $viewer; 14 return $this; 15 } 16 17 public function getViewer() { 18 return $this->viewer; 19 } 20 21 public function withPHIDs(array $phids) { 22 $this->phids = $phids; 23 return $this; 24 } 25 26 public function execute() { 27 $phids = array_fuse($this->phids); 28 $actors = array(); 29 $type_map = array(); 30 foreach ($phids as $phid) { 31 $type_map[phid_get_type($phid)][] = $phid; 32 } 33 34 // TODO: Generalize this somewhere else. 35 36 $results = array(); 37 foreach ($type_map as $type => $phids) { 38 switch ($type) { 39 case PhabricatorProjectProjectPHIDType::TYPECONST: 40 // NOTE: We're loading the projects here in order to respect policies. 41 42 $projects = id(new PhabricatorProjectQuery()) 43 ->setViewer($this->getViewer()) 44 ->withPHIDs($phids) 45 ->execute(); 46 47 $subscribers = id(new PhabricatorSubscribersQuery()) 48 ->withObjectPHIDs($phids) 49 ->execute(); 50 51 $projects = mpull($projects, null, 'getPHID'); 52 foreach ($phids as $phid) { 53 $project = idx($projects, $phid); 54 if (!$project) { 55 $results[$phid] = array(); 56 } else { 57 $results[$phid] = idx($subscribers, $phid, array()); 58 } 59 } 60 break; 61 default: 62 break; 63 } 64 } 65 66 return $results; 67 } 68 69 }
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 |