[ Index ] |
PHP Cross Reference of Phabricator |
[Summary view] [Print] [Text view]
1 <?php 2 3 final class PhortuneMerchant extends PhortuneDAO 4 implements PhabricatorPolicyInterface { 5 6 protected $name; 7 protected $viewPolicy; 8 protected $description; 9 10 private $memberPHIDs = self::ATTACHABLE; 11 12 public static function initializeNewMerchant(PhabricatorUser $actor) { 13 return id(new PhortuneMerchant()) 14 ->setViewPolicy(PhabricatorPolicies::getMostOpenPolicy()) 15 ->attachMemberPHIDs(array()); 16 } 17 18 public function getConfiguration() { 19 return array( 20 self::CONFIG_AUX_PHID => true, 21 self::CONFIG_COLUMN_SCHEMA => array( 22 'name' => 'text255', 23 'description' => 'text', 24 ), 25 ) + parent::getConfiguration(); 26 } 27 28 public function generatePHID() { 29 return PhabricatorPHID::generateNewPHID( 30 PhortuneMerchantPHIDType::TYPECONST); 31 } 32 33 public function getMemberPHIDs() { 34 return $this->assertAttached($this->memberPHIDs); 35 } 36 37 public function attachMemberPHIDs(array $member_phids) { 38 $this->memberPHIDs = $member_phids; 39 return $this; 40 } 41 42 43 /* -( PhabricatorPolicyInterface )----------------------------------------- */ 44 45 46 public function getCapabilities() { 47 return array( 48 PhabricatorPolicyCapability::CAN_VIEW, 49 PhabricatorPolicyCapability::CAN_EDIT, 50 ); 51 } 52 53 public function getPolicy($capability) { 54 switch ($capability) { 55 case PhabricatorPolicyCapability::CAN_VIEW: 56 return $this->getViewPolicy(); 57 case PhabricatorPolicyCapability::CAN_EDIT: 58 return PhabricatorPolicies::POLICY_NOONE; 59 } 60 } 61 62 public function hasAutomaticCapability($capability, PhabricatorUser $viewer) { 63 $members = array_fuse($this->getMemberPHIDs()); 64 if (isset($members[$viewer->getPHID()])) { 65 return true; 66 } 67 68 return false; 69 } 70 71 public function describeAutomaticCapability($capability) { 72 return pht("A merchant's members an always view and edit it."); 73 } 74 75 }
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 |