Correct a parameter order swap in "diffusion.historyquery" for Mercurial
[phabricator.git] / src / applications / herald / storage / transcript / HeraldConditionTranscript.php
blob31111608bf3a0ef0579108edaa81ab28abf1b08c
1 <?php
3 final class HeraldConditionTranscript extends Phobject {
5 protected $ruleID;
6 protected $conditionID;
7 protected $fieldName;
8 protected $condition;
9 protected $testValue;
10 protected $resultMap;
12 // See T13586. Older versions of this record stored a boolean true, boolean
13 // false, or the string "forbidden" in the "$result" field. They stored a
14 // human-readable English-language message or a state code in the "$note"
15 // field.
17 // The modern record does not use either field.
19 protected $result;
20 protected $note;
22 public function setRuleID($rule_id) {
23 $this->ruleID = $rule_id;
24 return $this;
27 public function getRuleID() {
28 return $this->ruleID;
31 public function setConditionID($condition_id) {
32 $this->conditionID = $condition_id;
33 return $this;
36 public function getConditionID() {
37 return $this->conditionID;
40 public function setFieldName($field_name) {
41 $this->fieldName = $field_name;
42 return $this;
45 public function getFieldName() {
46 return $this->fieldName;
49 public function setCondition($condition) {
50 $this->condition = $condition;
51 return $this;
54 public function getCondition() {
55 return $this->condition;
58 public function setTestValue($test_value) {
59 $this->testValue = $test_value;
60 return $this;
63 public function getTestValue() {
64 return $this->testValue;
67 public function setResult(HeraldConditionResult $result) {
68 $this->resultMap = $result->newResultMap();
69 return $this;
72 public function getResult() {
73 $map = $this->resultMap;
75 if (is_array($map)) {
76 $result = HeraldConditionResult::newFromResultMap($map);
77 } else {
78 $legacy_result = $this->result;
80 $result_data = array();
82 if ($legacy_result === 'forbidden') {
83 $result_code = HeraldConditionResult::RESULT_OBJECT_STATE;
84 $result_data = array(
85 'reason' => $this->note,
87 } else if ($legacy_result === true) {
88 $result_code = HeraldConditionResult::RESULT_MATCHED;
89 } else if ($legacy_result === false) {
90 $result_code = HeraldConditionResult::RESULT_FAILED;
91 } else {
92 $result_code = HeraldConditionResult::RESULT_UNKNOWN;
95 $result = HeraldConditionResult::newFromResultCode($result_code)
96 ->setResultData($result_data);
99 return $result;