Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/phabricator
Path: blob/master/src/applications/diffusion/data/DiffusionRepositoryRef.php
12241 views
1
<?php
2
3
/**
4
* @task serialization Serializing Repository Refs
5
*/
6
final class DiffusionRepositoryRef extends Phobject {
7
8
private $shortName;
9
private $commitIdentifier;
10
private $refType;
11
private $rawFields = array();
12
13
public function setRawFields(array $raw_fields) {
14
$this->rawFields = $raw_fields;
15
return $this;
16
}
17
18
public function getRawFields() {
19
return $this->rawFields;
20
}
21
22
public function setCommitIdentifier($commit_identifier) {
23
$this->commitIdentifier = $commit_identifier;
24
return $this;
25
}
26
27
public function getCommitIdentifier() {
28
return $this->commitIdentifier;
29
}
30
31
public function setShortName($short_name) {
32
$this->shortName = $short_name;
33
return $this;
34
}
35
36
public function getShortName() {
37
return $this->shortName;
38
}
39
40
public function setRefType($ref_type) {
41
$this->refType = $ref_type;
42
return $this;
43
}
44
45
public function getRefType() {
46
return $this->refType;
47
}
48
49
public function isBranch() {
50
$type_branch = PhabricatorRepositoryRefCursor::TYPE_BRANCH;
51
return ($this->getRefType() === $type_branch);
52
}
53
54
public function isTag() {
55
$type_tag = PhabricatorRepositoryRefCursor::TYPE_TAG;
56
return ($this->getRefType() === $type_tag);
57
}
58
59
60
/* -( Serialization )------------------------------------------------------ */
61
62
63
public function toDictionary() {
64
return array(
65
'shortName' => $this->shortName,
66
'commitIdentifier' => $this->commitIdentifier,
67
'refType' => $this->refType,
68
'rawFields' => $this->rawFields,
69
);
70
}
71
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']);
78
}
79
80
public static function loadAllFromDictionaries(array $dictionaries) {
81
$refs = array();
82
foreach ($dictionaries as $dictionary) {
83
$refs[] = self::newFromDictionary($dictionary);
84
}
85
return $refs;
86
}
87
88
}
89
90