[ Index ] |
PHP Cross Reference of Phabricator |
[Summary view] [Print] [Text view]
1 <?php 2 3 interface PhabricatorPolicyInterface extends PhabricatorPHIDInterface { 4 5 public function getCapabilities(); 6 public function getPolicy($capability); 7 public function hasAutomaticCapability($capability, PhabricatorUser $viewer); 8 9 /** 10 * Describe exceptions to an object's policy setting. 11 * 12 * The intent of this method is to explain and inform users about special 13 * cases which override configured policy settings. If this object has any 14 * such exceptions, explain them by returning one or more human-readable 15 * strings which describe the exception in a broad, categorical way. For 16 * example: 17 * 18 * - "The owner of an X can always view and edit it." 19 * - "Members of a Y can always view it." 20 * 21 * You can return `null`, a single string, or a list of strings. 22 * 23 * The relevant capability to explain (like "view") is passed as a parameter. 24 * You should tailor any messages to be relevant to that capability, although 25 * they do not need to exclusively describe the capability, and in some cases 26 * being more general ("The author can view and edit...") will be more clear. 27 * 28 * Messages should describe general rules, not specific objects, because the 29 * main goal is to teach the user the rules. For example, write "the author", 30 * not the specific author's name. 31 * 32 * @param const @{class:PhabricatorPolicyCapability} constant. 33 * @return wild Description of policy exceptions. See above. 34 */ 35 public function describeAutomaticCapability($capability); 36 37 } 38 39 // TEMPLATE IMPLEMENTATION ///////////////////////////////////////////////////// 40 41 /* -( PhabricatorPolicyInterface )----------------------------------------- */ 42 /* 43 44 public function getCapabilities() { 45 return array( 46 PhabricatorPolicyCapability::CAN_VIEW, 47 ); 48 } 49 50 public function getPolicy($capability) { 51 switch ($capability) { 52 case PhabricatorPolicyCapability::CAN_VIEW: 53 return PhabricatorPolicies::POLICY_USER; 54 } 55 } 56 57 public function hasAutomaticCapability($capability, PhabricatorUser $viewer) { 58 return false; 59 } 60 61 public function describeAutomaticCapability($capability) { 62 return null; 63 } 64 65 */
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 |