Path: blob/master/src/applications/herald/storage/transcript/HeraldTranscriptResult.php
12262 views
<?php12abstract class HeraldTranscriptResult3extends Phobject {45private $resultCode;6private $resultData = array();78final protected function setResultCode($result_code) {9$this->resultCode = $result_code;10return $this;11}1213final protected function loadFromResultMap(array $map) {14$result_code = idx($map, 'code');15$result_data = idx($map, 'data', array());1617$this18->setResultCode($result_code)19->setResultData($result_data);2021return $this;22}2324final public function getResultCode() {25return $this->resultCode;26}2728final protected function getResultData() {29return $this->resultData;30}3132final public function setResultData(array $result_data) {33$this->resultData = $result_data;34return $this;35}3637final public function getIconIcon() {38return $this->getSpecificationProperty('icon');39}4041final public function getIconColor() {42return $this->getSpecificationProperty('color.icon');43}4445final public function getName() {46return $this->getSpecificationProperty('name');47}4849abstract public function newDetailsView(PhabricatorUser $viewer);5051final protected function getDataProperty($key, $default = null) {52$data = $this->getResultData();53return idx($data, $key, $default);54}5556final public function newResultMap() {57return array(58'code' => $this->getResultCode(),59'data' => $this->getResultData(),60);61}6263final protected function getSpecificationProperty($key) {64$map = $this->getResultSpecification($this->getResultCode());65return $map[$key];66}6768final protected function getResultSpecification($result_code) {69$map = $this->newResultSpecificationMap();7071if (!isset($map[$result_code])) {72throw new Exception(73pht(74'Result code "%s" is unknown.',75$result_code));76}7778return $map[$result_code];79}8081abstract protected function newResultSpecificationMap();8283final protected function newErrorView($error_class, $error_message) {84return pht(85'%s: %s',86phutil_tag('strong', array(), $error_class),87phutil_escape_html_newlines($error_message));88}8990}919293