Changeset View
Changeset View
Standalone View
Standalone View
src/applications/herald/storage/transcript/HeraldConditionResult.php
<?php | <?php | ||||
final class HeraldConditionResult | final class HeraldConditionResult | ||||
extends HeraldTranscriptResult { | extends HeraldTranscriptResult { | ||||
const RESULT_MATCHED = 'matched'; | const RESULT_MATCHED = 'matched'; | ||||
const RESULT_FAILED = 'failed'; | const RESULT_FAILED = 'failed'; | ||||
const RESULT_OBJECT_STATE = 'object-state'; | const RESULT_OBJECT_STATE = 'object-state'; | ||||
const RESULT_INVALID = 'invalid'; | const RESULT_INVALID = 'invalid'; | ||||
const RESULT_RECURSION = 'recursion'; | |||||
const RESULT_EXCEPTION = 'exception'; | const RESULT_EXCEPTION = 'exception'; | ||||
const RESULT_UNKNOWN = 'unknown'; | const RESULT_UNKNOWN = 'unknown'; | ||||
public static function newFromResultCode($result_code) { | public static function newFromResultCode($result_code) { | ||||
return id(new self())->setResultCode($result_code); | return id(new self())->setResultCode($result_code); | ||||
} | } | ||||
public static function newFromResultMap(array $map) { | public static function newFromResultMap(array $map) { | ||||
return id(new self())->loadFromResultMap($map); | return id(new self())->loadFromResultMap($map); | ||||
} | } | ||||
public function getIsMatch() { | public function getIsMatch() { | ||||
return ($this->getSpecificationProperty('match') === true); | return ($this->getSpecificationProperty('match') === true); | ||||
} | } | ||||
public function newDetailsView() { | public function newDetailsView(PhabricatorUser $viewer) { | ||||
switch ($this->getResultCode()) { | switch ($this->getResultCode()) { | ||||
case self::RESULT_OBJECT_STATE: | case self::RESULT_OBJECT_STATE: | ||||
$reason = $this->getDataProperty('reason'); | $reason = $this->getDataProperty('reason'); | ||||
$details = HeraldStateReasons::getExplanation($reason); | $details = HeraldStateReasons::getExplanation($reason); | ||||
break; | break; | ||||
case self::RESULT_INVALID: | case self::RESULT_INVALID: | ||||
case self::RESULT_EXCEPTION: | case self::RESULT_EXCEPTION: | ||||
$error_class = $this->getDataProperty('exception.class'); | $error_class = $this->getDataProperty('exception.class'); | ||||
Show All 15 Lines | switch ($this->getResultCode()) { | ||||
'additional information is available.'); | 'additional information is available.'); | ||||
} | } | ||||
$details = pht( | $details = pht( | ||||
'%s: %s', | '%s: %s', | ||||
phutil_tag('strong', array(), $error_class), | phutil_tag('strong', array(), $error_class), | ||||
phutil_escape_html_newlines($error_message)); | phutil_escape_html_newlines($error_message)); | ||||
break; | break; | ||||
$details = 'exception'; | |||||
break; | |||||
default: | default: | ||||
$details = null; | $details = null; | ||||
break; | break; | ||||
} | } | ||||
return $details; | return $details; | ||||
} | } | ||||
Show All 18 Lines | return array( | ||||
'name' => pht('Forbidden'), | 'name' => pht('Forbidden'), | ||||
), | ), | ||||
self::RESULT_INVALID => array( | self::RESULT_INVALID => array( | ||||
'match' => null, | 'match' => null, | ||||
'icon' => 'fa-exclamation-triangle', | 'icon' => 'fa-exclamation-triangle', | ||||
'color.icon' => 'yellow', | 'color.icon' => 'yellow', | ||||
'name' => pht('Invalid'), | 'name' => pht('Invalid'), | ||||
), | ), | ||||
self::RESULT_RECURSION => array( | |||||
'match' => null, | |||||
'icon' => 'fa-exclamation-triangle', | |||||
'color.icon' => 'red', | |||||
'name' => pht('Recursion'), | |||||
), | |||||
self::RESULT_EXCEPTION => array( | self::RESULT_EXCEPTION => array( | ||||
'match' => null, | 'match' => null, | ||||
'icon' => 'fa-exclamation-triangle', | 'icon' => 'fa-exclamation-triangle', | ||||
'color.icon' => 'red', | 'color.icon' => 'red', | ||||
'name' => pht('Exception'), | 'name' => pht('Exception'), | ||||
), | ), | ||||
self::RESULT_UNKNOWN => array( | self::RESULT_UNKNOWN => array( | ||||
'match' => null, | 'match' => null, | ||||
'icon' => 'fa-question', | 'icon' => 'fa-question', | ||||
'color.icon' => 'grey', | 'color.icon' => 'grey', | ||||
'name' => pht('Unknown'), | 'name' => pht('Unknown'), | ||||
), | ), | ||||
); | ); | ||||
} | } | ||||
} | } |