4 * @task serialization Serializing Repository Refs
6 final class DiffusionRepositoryRef
extends Phobject
{
9 private $commitIdentifier;
11 private $rawFields = array();
13 public function setRawFields(array $raw_fields) {
14 $this->rawFields
= $raw_fields;
18 public function getRawFields() {
19 return $this->rawFields
;
22 public function setCommitIdentifier($commit_identifier) {
23 $this->commitIdentifier
= $commit_identifier;
27 public function getCommitIdentifier() {
28 return $this->commitIdentifier
;
31 public function setShortName($short_name) {
32 $this->shortName
= $short_name;
36 public function getShortName() {
37 return $this->shortName
;
40 public function setRefType($ref_type) {
41 $this->refType
= $ref_type;
45 public function getRefType() {
46 return $this->refType
;
49 public function isBranch() {
50 $type_branch = PhabricatorRepositoryRefCursor
::TYPE_BRANCH
;
51 return ($this->getRefType() === $type_branch);
54 public function isTag() {
55 $type_tag = PhabricatorRepositoryRefCursor
::TYPE_TAG
;
56 return ($this->getRefType() === $type_tag);
60 /* -( Serialization )------------------------------------------------------ */
63 public function toDictionary() {
65 'shortName' => $this->shortName
,
66 'commitIdentifier' => $this->commitIdentifier
,
67 'refType' => $this->refType
,
68 'rawFields' => $this->rawFields
,
72 public static function newFromDictionary(array $dict) {
73 return id(new DiffusionRepositoryRef())
74 ->setShortName($dict['shortName'])
75 ->setCommitIdentifier($dict['commitIdentifier'])
76 ->setRefType($dict['refType'])
77 ->setRawFields($dict['rawFields']);
80 public static function loadAllFromDictionaries(array $dictionaries) {
82 foreach ($dictionaries as $dictionary) {
83 $refs[] = self
::newFromDictionary($dictionary);