Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/phabricator
Path: blob/master/src/applications/harbormaster/engine/HarbormasterBuildableEngine.php
12256 views
1
<?php
2
3
abstract class HarbormasterBuildableEngine
4
extends Phobject {
5
6
private $viewer;
7
private $actingAsPHID;
8
private $contentSource;
9
private $object;
10
11
final public function setViewer(PhabricatorUser $viewer) {
12
$this->viewer = $viewer;
13
return $this;
14
}
15
16
final public function getViewer() {
17
return $this->viewer;
18
}
19
20
final public function setActingAsPHID($acting_as_phid) {
21
$this->actingAsPHID = $acting_as_phid;
22
return $this;
23
}
24
25
final public function getActingAsPHID() {
26
return $this->actingAsPHID;
27
}
28
29
final public function setContentSource(
30
PhabricatorContentSource $content_source) {
31
$this->contentSource = $content_source;
32
return $this;
33
}
34
35
final public function getContentSource() {
36
return $this->contentSource;
37
}
38
39
final public function setObject(HarbormasterBuildableInterface $object) {
40
$this->object = $object;
41
return $this;
42
}
43
44
final public function getObject() {
45
return $this->object;
46
}
47
48
protected function getPublishableObject() {
49
return $this->getObject();
50
}
51
52
public function publishBuildable(
53
HarbormasterBuildable $old,
54
HarbormasterBuildable $new) {
55
return;
56
}
57
58
final public static function newForObject(
59
HarbormasterBuildableInterface $object,
60
PhabricatorUser $viewer) {
61
return $object->newBuildableEngine()
62
->setViewer($viewer)
63
->setObject($object);
64
}
65
66
final protected function newEditor() {
67
$publishable = $this->getPublishableObject();
68
69
$viewer = $this->getViewer();
70
71
$editor = $publishable->getApplicationTransactionEditor()
72
->setActor($viewer)
73
->setContinueOnNoEffect(true)
74
->setContinueOnMissingFields(true);
75
76
$acting_as_phid = $this->getActingAsPHID();
77
if ($acting_as_phid !== null) {
78
$editor->setActingAsPHID($acting_as_phid);
79
}
80
81
$content_source = $this->getContentSource();
82
if ($content_source !== null) {
83
$editor->setContentSource($content_source);
84
}
85
86
return $editor;
87
}
88
89
final protected function newTransaction() {
90
$publishable = $this->getPublishableObject();
91
92
return $publishable->getApplicationTransactionTemplate();
93
}
94
95
final protected function applyTransactions(array $xactions) {
96
$publishable = $this->getPublishableObject();
97
$editor = $this->newEditor();
98
99
$editor->applyTransactions($publishable, $xactions);
100
}
101
102
public function getAuthorIdentity() {
103
return null;
104
}
105
106
}
107
108