Path: blob/master/src/applications/herald/storage/transcript/HeraldConditionTranscript.php
12261 views
<?php12final class HeraldConditionTranscript extends Phobject {34protected $ruleID;5protected $conditionID;6protected $fieldName;7protected $condition;8protected $testValue;9protected $resultMap;1011// See T13586. Older versions of this record stored a boolean true, boolean12// false, or the string "forbidden" in the "$result" field. They stored a13// human-readable English-language message or a state code in the "$note"14// field.1516// The modern record does not use either field.1718protected $result;19protected $note;2021public function setRuleID($rule_id) {22$this->ruleID = $rule_id;23return $this;24}2526public function getRuleID() {27return $this->ruleID;28}2930public function setConditionID($condition_id) {31$this->conditionID = $condition_id;32return $this;33}3435public function getConditionID() {36return $this->conditionID;37}3839public function setFieldName($field_name) {40$this->fieldName = $field_name;41return $this;42}4344public function getFieldName() {45return $this->fieldName;46}4748public function setCondition($condition) {49$this->condition = $condition;50return $this;51}5253public function getCondition() {54return $this->condition;55}5657public function setTestValue($test_value) {58$this->testValue = $test_value;59return $this;60}6162public function getTestValue() {63return $this->testValue;64}6566public function setResult(HeraldConditionResult $result) {67$this->resultMap = $result->newResultMap();68return $this;69}7071public function getResult() {72$map = $this->resultMap;7374if (is_array($map)) {75$result = HeraldConditionResult::newFromResultMap($map);76} else {77$legacy_result = $this->result;7879$result_data = array();8081if ($legacy_result === 'forbidden') {82$result_code = HeraldConditionResult::RESULT_OBJECT_STATE;83$result_data = array(84'reason' => $this->note,85);86} else if ($legacy_result === true) {87$result_code = HeraldConditionResult::RESULT_MATCHED;88} else if ($legacy_result === false) {89$result_code = HeraldConditionResult::RESULT_FAILED;90} else {91$result_code = HeraldConditionResult::RESULT_UNKNOWN;92}9394$result = HeraldConditionResult::newFromResultCode($result_code)95->setResultData($result_data);96}9798return $result;99}100101}102103104