Differential D14467 Diff 35710 src/applications/subscriptions/policyrule/PhabricatorSubscriptionsSubscribersPolicyRule.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/subscriptions/policyrule/PhabricatorSubscriptionsSubscribersPolicyRule.php
<?php | <?php | ||||
final class PhabricatorSubscriptionsSubscribersPolicyRule | final class PhabricatorSubscriptionsSubscribersPolicyRule | ||||
extends PhabricatorPolicyRule { | extends PhabricatorPolicyRule { | ||||
private $subscribed = array(); | private $subscribed = array(); | ||||
private $sourcePHIDs = array(); | private $sourcePHIDs = array(); | ||||
public function getObjectPolicyKey() { | |||||
return 'subscriptions.subscribers'; | |||||
} | |||||
public function getObjectPolicyName() { | |||||
return pht('Subscribers'); | |||||
} | |||||
public function getPolicyExplanation() { | |||||
return pht('Subscribers can take this action.'); | |||||
} | |||||
public function getRuleDescription() { | public function getRuleDescription() { | ||||
return pht('subscribers'); | return pht('subscribers'); | ||||
} | } | ||||
public function canApplyToObject(PhabricatorPolicyInterface $object) { | |||||
return ($object instanceof PhabricatorSubscribableInterface); | |||||
} | |||||
public function willApplyRules( | public function willApplyRules( | ||||
PhabricatorUser $viewer, | PhabricatorUser $viewer, | ||||
array $values, | array $values, | ||||
array $objects) { | array $objects) { | ||||
// We want to let the user see the object if they're a subscriber or | // We want to let the user see the object if they're a subscriber or | ||||
// a member of any project which is a subscriber. Additionally, because | // a member of any project which is a subscriber. Additionally, because | ||||
// subscriber state is complex, we need to read hints passed from | // subscriber state is complex, we need to read hints passed from | ||||
▲ Show 20 Lines • Show All 76 Lines • ▼ Show 20 Lines | public function applyRule( | ||||
$subscribed = idx($this->subscribed, $viewer_phid); | $subscribed = idx($this->subscribed, $viewer_phid); | ||||
return isset($subscribed[$object->getPHID()]); | return isset($subscribed[$object->getPHID()]); | ||||
} | } | ||||
public function getValueControlType() { | public function getValueControlType() { | ||||
return self::CONTROL_TYPE_NONE; | return self::CONTROL_TYPE_NONE; | ||||
} | } | ||||
public function canApplyToObject(PhabricatorPolicyInterface $object) { | |||||
return $object instanceof PhabricatorSubscribableInterface; | |||||
} | |||||
public function getObjectPolicyKey() { | |||||
return 'subscriptions.subscribers'; | |||||
} | |||||
public function getObjectPolicyName() { | |||||
return pht('Subscribers'); | |||||
} | |||||
public function getPolicyExplanation() { | |||||
return pht('Subscribers can take this action.'); | |||||
} | |||||
epriestley: Minor, but I think these classes read slightly better if these short, descriptive methods are… | |||||
} | } |
Minor, but I think these classes read slightly better if these short, descriptive methods are at the top of the file. If you're seeking to understand what a class does, these methods are more informative at a glance than methods like applyRule().