[ Index ] |
PHP Cross Reference of Phabricator |
[Summary view] [Print] [Text view]
1 <?php 2 3 final class FundBackerCart extends PhortuneCartImplementation { 4 5 private $initiativePHID; 6 private $initiative; 7 8 public function setInitiativePHID($initiative_phid) { 9 $this->initiativePHID = $initiative_phid; 10 return $this; 11 } 12 13 public function getInitiativePHID() { 14 return $this->initiativePHID; 15 } 16 17 public function setInitiative(FundInitiative $initiative) { 18 $this->initiative = $initiative; 19 return $this; 20 } 21 22 public function getInitiative() { 23 return $this->initiative; 24 } 25 26 public function getName(PhortuneCart $cart) { 27 return pht('Fund Initiative'); 28 } 29 30 public function willCreateCart( 31 PhabricatorUser $viewer, 32 PhortuneCart $cart) { 33 34 $initiative = $this->getInitiative(); 35 if (!$initiative) { 36 throw new Exception( 37 pht('Call setInitiative() before building a cart!')); 38 } 39 40 $cart->setMetadataValue('initiativePHID', $initiative->getPHID()); 41 } 42 43 public function loadImplementationsForCarts( 44 PhabricatorUser $viewer, 45 array $carts) { 46 47 $phids = array(); 48 foreach ($carts as $cart) { 49 $phids[] = $cart->getMetadataValue('initiativePHID'); 50 } 51 52 $initiatives = id(new FundInitiativeQuery()) 53 ->setViewer($viewer) 54 ->withPHIDs($phids) 55 ->execute(); 56 $initiatives = mpull($initiatives, null, 'getPHID'); 57 58 $objects = array(); 59 foreach ($carts as $key => $cart) { 60 $initiative_phid = $cart->getMetadataValue('initiativePHID'); 61 62 $object = id(new FundBackerCart()) 63 ->setInitiativePHID($initiative_phid); 64 65 $initiative = idx($initiatives, $initiative_phid); 66 if ($initiative) { 67 $object->setInitiative($initiative); 68 } 69 70 $objects[$key] = $object; 71 } 72 73 return $objects; 74 } 75 76 public function getCancelURI(PhortuneCart $cart) { 77 return '/'.$this->getInitiative()->getMonogram(); 78 } 79 80 public function getDoneURI(PhortuneCart $cart) { 81 return '/'.$this->getInitiative()->getMonogram(); 82 } 83 84 public function getDoneActionName(PhortuneCart $cart) { 85 return pht('Return to Initiative'); 86 } 87 88 }
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 |