Changeset View
Changeset View
Standalone View
Standalone View
src/applications/herald/adapter/HeraldAdapter.php
Show All 20 Lines | abstract class HeraldAdapter extends Phobject { | ||||
const CONDITION_NOT_EXISTS = '!exists'; | const CONDITION_NOT_EXISTS = '!exists'; | ||||
const CONDITION_UNCONDITIONALLY = 'unconditionally'; | const CONDITION_UNCONDITIONALLY = 'unconditionally'; | ||||
const CONDITION_NEVER = 'never'; | const CONDITION_NEVER = 'never'; | ||||
const CONDITION_REGEXP_PAIR = 'regexp-pair'; | const CONDITION_REGEXP_PAIR = 'regexp-pair'; | ||||
const CONDITION_HAS_BIT = 'bit'; | const CONDITION_HAS_BIT = 'bit'; | ||||
const CONDITION_NOT_BIT = '!bit'; | const CONDITION_NOT_BIT = '!bit'; | ||||
const CONDITION_IS_TRUE = 'true'; | const CONDITION_IS_TRUE = 'true'; | ||||
const CONDITION_IS_FALSE = 'false'; | const CONDITION_IS_FALSE = 'false'; | ||||
const CONDITION_MOVED_TO = 'moved-to'; | |||||
private $contentSource; | private $contentSource; | ||||
private $isNewObject; | private $isNewObject; | ||||
private $applicationEmail; | private $applicationEmail; | ||||
private $appliedTransactions = array(); | private $appliedTransactions = array(); | ||||
private $queuedTransactions = array(); | private $queuedTransactions = array(); | ||||
private $emailPHIDs = array(); | private $emailPHIDs = array(); | ||||
private $forcedEmailPHIDs = array(); | private $forcedEmailPHIDs = array(); | ||||
▲ Show 20 Lines • Show All 307 Lines • ▼ Show 20 Lines | return array( | ||||
self::CONDITION_NOT_RULE => pht('does not match:'), | self::CONDITION_NOT_RULE => pht('does not match:'), | ||||
self::CONDITION_EXISTS => pht('exists'), | self::CONDITION_EXISTS => pht('exists'), | ||||
self::CONDITION_NOT_EXISTS => pht('does not exist'), | self::CONDITION_NOT_EXISTS => pht('does not exist'), | ||||
self::CONDITION_UNCONDITIONALLY => '', // don't show anything! | self::CONDITION_UNCONDITIONALLY => '', // don't show anything! | ||||
self::CONDITION_NEVER => '', // don't show anything! | self::CONDITION_NEVER => '', // don't show anything! | ||||
self::CONDITION_REGEXP_PAIR => pht('matches regexp pair'), | self::CONDITION_REGEXP_PAIR => pht('matches regexp pair'), | ||||
self::CONDITION_HAS_BIT => pht('has bit'), | self::CONDITION_HAS_BIT => pht('has bit'), | ||||
self::CONDITION_NOT_BIT => pht('lacks bit'), | self::CONDITION_NOT_BIT => pht('lacks bit'), | ||||
self::CONDITION_MOVED_TO => pht('moved to any of'), | |||||
); | ); | ||||
} | } | ||||
public function getConditionsForField($field) { | public function getConditionsForField($field) { | ||||
return $this->requireFieldImplementation($field) | return $this->requireFieldImplementation($field) | ||||
->getHeraldFieldConditions(); | ->getHeraldFieldConditions(); | ||||
} | } | ||||
Show All 38 Lines | switch ($condition_type) { | ||||
return ($field_value == $condition_value); | return ($field_value == $condition_value); | ||||
case self::CONDITION_IS_NOT: | case self::CONDITION_IS_NOT: | ||||
return ($field_value != $condition_value); | return ($field_value != $condition_value); | ||||
case self::CONDITION_IS_ME: | case self::CONDITION_IS_ME: | ||||
return ($field_value == $rule->getAuthorPHID()); | return ($field_value == $rule->getAuthorPHID()); | ||||
case self::CONDITION_IS_NOT_ME: | case self::CONDITION_IS_NOT_ME: | ||||
return ($field_value != $rule->getAuthorPHID()); | return ($field_value != $rule->getAuthorPHID()); | ||||
case self::CONDITION_IS_ANY: | case self::CONDITION_IS_ANY: | ||||
case self::CONDITION_MOVED_TO: | |||||
if (!is_array($condition_value)) { | if (!is_array($condition_value)) { | ||||
throw new HeraldInvalidConditionException( | throw new HeraldInvalidConditionException( | ||||
pht('Expected condition value to be an array.')); | pht('Expected condition value to be an array.')); | ||||
} | } | ||||
$condition_value = array_fuse($condition_value); | $condition_value = array_fuse($condition_value); | ||||
return isset($condition_value[$field_value]); | return isset($condition_value[$field_value]); | ||||
case self::CONDITION_IS_NOT_ANY: | case self::CONDITION_IS_NOT_ANY: | ||||
if (!is_array($condition_value)) { | if (!is_array($condition_value)) { | ||||
▲ Show 20 Lines • Show All 186 Lines • ▼ Show 20 Lines | switch ($condition_type) { | ||||
case self::CONDITION_EXISTS: | case self::CONDITION_EXISTS: | ||||
case self::CONDITION_NOT_EXISTS: | case self::CONDITION_NOT_EXISTS: | ||||
case self::CONDITION_UNCONDITIONALLY: | case self::CONDITION_UNCONDITIONALLY: | ||||
case self::CONDITION_NEVER: | case self::CONDITION_NEVER: | ||||
case self::CONDITION_HAS_BIT: | case self::CONDITION_HAS_BIT: | ||||
case self::CONDITION_NOT_BIT: | case self::CONDITION_NOT_BIT: | ||||
case self::CONDITION_IS_TRUE: | case self::CONDITION_IS_TRUE: | ||||
case self::CONDITION_IS_FALSE: | case self::CONDITION_IS_FALSE: | ||||
case self::CONDITION_MOVED_TO: | |||||
// No explicit validation for these types, although there probably | // No explicit validation for these types, although there probably | ||||
// should be in some cases. | // should be in some cases. | ||||
break; | break; | ||||
default: | default: | ||||
throw new HeraldInvalidConditionException( | throw new HeraldInvalidConditionException( | ||||
pht( | pht( | ||||
'Unknown condition "%s"!', | 'Unknown condition "%s"!', | ||||
$condition_type)); | $condition_type)); | ||||
▲ Show 20 Lines • Show All 504 Lines • Show Last 20 Lines |