Changeset View
Changeset View
Standalone View
Standalone View
src/ref/revision/ArcanistRevisionRef.php
| Show All 20 Lines | final class ArcanistRevisionRef | ||||
| } | } | ||||
| public static function newFromConduit(array $dict) { | public static function newFromConduit(array $dict) { | ||||
| $ref = new self(); | $ref = new self(); | ||||
| $ref->parameters = $dict; | $ref->parameters = $dict; | ||||
| return $ref; | return $ref; | ||||
| } | } | ||||
| public static function newFromConduitQuery(array $dict) { | |||||
| // Mangle an older "differential.query" result to look like a modern | |||||
| // "differential.revision.search" result. | |||||
| $status_name = idx($dict, 'statusName'); | |||||
| switch ($status_name) { | |||||
| case 'Abandoned': | |||||
| case 'Closed': | |||||
| $is_closed = true; | |||||
| break; | |||||
| default: | |||||
| $is_closed = false; | |||||
| break; | |||||
| } | |||||
| $dict['fields'] = array( | |||||
| 'uri' => idx($dict, 'uri'), | |||||
| 'title' => idx($dict, 'title'), | |||||
| 'authorPHID' => idx($dict, 'authorPHID'), | |||||
| 'status' => array( | |||||
| 'name' => $status_name, | |||||
| 'closed' => $is_closed, | |||||
| ), | |||||
| ); | |||||
| return self::newFromConduit($dict); | |||||
| } | |||||
| public function getMonogram() { | public function getMonogram() { | ||||
| return 'D'.$this->getID(); | return 'D'.$this->getID(); | ||||
| } | } | ||||
| public function getStatusDisplayName() { | public function getStatusDisplayName() { | ||||
| return idx($this->parameters, 'statusName'); | return idxv($this->parameters, array('fields', 'status', 'name')); | ||||
| } | } | ||||
| public function isClosed() { | public function isClosed() { | ||||
| // TODO: This should use sensible constants, not English language | return idxv($this->parameters, array('fields', 'status', 'closed')); | ||||
| // display text. | |||||
| switch ($this->getStatusDisplayName()) { | |||||
| case 'Abandoned': | |||||
| case 'Closed': | |||||
| return true; | |||||
| } | } | ||||
| return false; | public function getURI() { | ||||
| $uri = idxv($this->parameters, array('fields', 'uri')); | |||||
| if ($uri === null) { | |||||
| // TODO: The "uri" field was added at the same time as this callsite, | |||||
| // so we may not have it yet if the server is running an older version | |||||
| // of Phabricator. Fake our way through. | |||||
| $uri = '/'.$this->getMonogram(); | |||||
| } | } | ||||
| public function getURI() { | return $uri; | ||||
| return idx($this->parameters, 'uri'); | |||||
| } | } | ||||
| public function getFullName() { | public function getFullName() { | ||||
| return pht('%s: %s', $this->getMonogram(), $this->getName()); | return pht('%s: %s', $this->getMonogram(), $this->getName()); | ||||
| } | } | ||||
| public function getID() { | public function getID() { | ||||
| return (int)idx($this->parameters, 'id'); | return (int)idx($this->parameters, 'id'); | ||||
| } | } | ||||
| public function getPHID() { | public function getPHID() { | ||||
| return idx($this->parameters, 'phid'); | return idx($this->parameters, 'phid'); | ||||
| } | } | ||||
| public function getName() { | public function getName() { | ||||
| return idx($this->parameters, 'title'); | return idxv($this->parameters, array('fields', 'title')); | ||||
| } | } | ||||
| public function getAuthorPHID() { | public function getAuthorPHID() { | ||||
| return idx($this->parameters, 'authorPHID'); | return idxv($this->parameters, array('fields', 'authorPHID')); | ||||
| } | } | ||||
| public function addSource(ArcanistRevisionRefSource $source) { | public function addSource(ArcanistRevisionRefSource $source) { | ||||
| $this->sources[] = $source; | $this->sources[] = $source; | ||||
| return $this; | return $this; | ||||
| } | } | ||||
| public function getSources() { | public function getSources() { | ||||
| Show All 16 Lines | |||||