forked from phacility/phabricator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDiffusionRepositoryRef.php
88 lines (69 loc) · 2.02 KB
/
DiffusionRepositoryRef.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
<?php
/**
* @task serialization Serializing Repository Refs
*/
final class DiffusionRepositoryRef extends Phobject {
private $shortName;
private $commitIdentifier;
private $refType;
private $rawFields = array();
public function setRawFields(array $raw_fields) {
$this->rawFields = $raw_fields;
return $this;
}
public function getRawFields() {
return $this->rawFields;
}
public function setCommitIdentifier($commit_identifier) {
$this->commitIdentifier = $commit_identifier;
return $this;
}
public function getCommitIdentifier() {
return $this->commitIdentifier;
}
public function setShortName($short_name) {
$this->shortName = $short_name;
return $this;
}
public function getShortName() {
return $this->shortName;
}
public function setRefType($ref_type) {
$this->refType = $ref_type;
return $this;
}
public function getRefType() {
return $this->refType;
}
public function isBranch() {
$type_branch = PhabricatorRepositoryRefCursor::TYPE_BRANCH;
return ($this->getRefType() === $type_branch);
}
public function isTag() {
$type_tag = PhabricatorRepositoryRefCursor::TYPE_TAG;
return ($this->getRefType() === $type_tag);
}
/* -( Serialization )------------------------------------------------------ */
public function toDictionary() {
return array(
'shortName' => $this->shortName,
'commitIdentifier' => $this->commitIdentifier,
'refType' => $this->refType,
'rawFields' => $this->rawFields,
);
}
public static function newFromDictionary(array $dict) {
return id(new DiffusionRepositoryRef())
->setShortName($dict['shortName'])
->setCommitIdentifier($dict['commitIdentifier'])
->setRefType($dict['refType'])
->setRawFields($dict['rawFields']);
}
public static function loadAllFromDictionaries(array $dictionaries) {
$refs = array();
foreach ($dictionaries as $dictionary) {
$refs[] = self::newFromDictionary($dictionary);
}
return $refs;
}
}