Page MenuHomeClusterLabs Projects
Diviner Tech Docs PhabricatorPolicyRule

abstract class PhabricatorPolicyRule
Phorge Technical Documentation (Policy)

This class is not documented.

Tasks

Implementing Object Policies

  • public function getObjectPolicyKey() — Return a unique string like "maniphest.author" to expose this rule as an object policy.

Other Methods

Methods

abstract public function getRuleDescription()

This method is not documented.
Return
wild

public function willApplyRules($viewer, $values, $objects)

This method is not documented.
Parameters
PhabricatorUser$viewer
array$values
array$objects
Return
wild

abstract public function applyRule($viewer, $value, $object)

This method is not documented.
Parameters
PhabricatorUser$viewer
$value
PhabricatorPolicyInterface$object
Return
wild

public function getValueControlType()

This method is not documented.
Return
wild

public function getValueControlTemplate()

This method is not documented.
Return
wild

public function canApplyToObject($object)

Return true if this rule can be applied to the given object.

Some policy rules may only operation on certain kinds of objects. For example, a "task author" rule can only operate on tasks.

Parameters
PhabricatorPolicyInterface$object
Return
wild

protected function getDatasourceTemplate($datasource)

This method is not documented.
Parameters
PhabricatorTypeaheadDatasource$datasource
Return
wild

public function getRuleOrder()

This method is not documented.
Return
wild

public function getValueForStorage($value)

This method is not documented.
Parameters
$value
Return
wild

public function getValueForDisplay($viewer, $value)

This method is not documented.
Parameters
PhabricatorUser$viewer
$value
Return
wild

public function getRequiredHandlePHIDsForSummary($value)

This method is not documented.
Parameters
$value
Return
wild

public function ruleHasEffect($value)

Return true if the given value creates a rule with a meaningful effect. An example of a rule with no meaningful effect is a "users" rule with no users specified.

Parameters
$value
Return
boolTrue if the value creates a meaningful rule.

public static function passTransactionHintToRule($object, $rule, $hint)

Tell policy rules about upcoming transaction effects.

Before transaction effects are applied, we try to stop users from making edits which will lock them out of objects. We can't do this perfectly, since they can set a policy to "the moon is full" moments before it wanes, but we try to prevent as many mistakes as possible.

Some policy rules depend on complex checks against object state which we can't set up ahead of time. For example, subscriptions require database writes.

In cases like this, instead of doing writes, you can pass a hint about an object to a policy rule. The rule can then look for hints and use them in rendering a verdict about whether the user will be able to see the object or not after applying the policy change.

Parameters
PhabricatorPolicyInterface$objectObject to pass a hint about.
PhabricatorPolicyRule$ruleRule to pass hint to.
wild$hintHint.
Return
void

final protected function getTransactionHint($object)

This method is not documented.
Parameters
PhabricatorPolicyInterface$object
Return
wild

private static function getObjectPolicyCacheKey($object, $rule)

This method is not documented.
Parameters
PhabricatorPolicyInterface$object
PhabricatorPolicyRule$rule
Return
wild

public function getObjectPolicyKey()

Return a unique string like "maniphest.author" to expose this rule as an object policy.

Object policy rules, like "Task Author", are more advanced than basic policy rules (like "All Users") but not as powerful as custom rules.

Return
stringUnique identifier for this rule.

final public function getObjectPolicyFullKey()

This method is not documented.
Return
wild

public function getObjectPolicyName()

This method is not documented.
Return
wild

public function getObjectPolicyShortName()

This method is not documented.
Return
wild

public function getObjectPolicyIcon()

This method is not documented.
Return
wild

public function getPolicyExplanation()

This method is not documented.
Return
wild