2018-04-03 13:39:48 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
abstract class HarbormasterBuildableEngine
|
2018-04-03 14:48:40 +02:00
|
|
|
extends Phobject {
|
|
|
|
|
|
|
|
private $viewer;
|
|
|
|
private $actingAsPHID;
|
|
|
|
private $contentSource;
|
|
|
|
private $object;
|
|
|
|
|
|
|
|
final public function setViewer(PhabricatorUser $viewer) {
|
|
|
|
$this->viewer = $viewer;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
final public function getViewer() {
|
|
|
|
return $this->viewer;
|
|
|
|
}
|
|
|
|
|
|
|
|
final public function setActingAsPHID($acting_as_phid) {
|
|
|
|
$this->actingAsPHID = $acting_as_phid;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
final public function getActingAsPHID() {
|
|
|
|
return $this->actingAsPHID;
|
|
|
|
}
|
|
|
|
|
|
|
|
final public function setContentSource(
|
|
|
|
PhabricatorContentSource $content_source) {
|
|
|
|
$this->contentSource = $content_source;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
final public function getContentSource() {
|
|
|
|
return $this->contentSource;
|
|
|
|
}
|
|
|
|
|
|
|
|
final public function setObject(HarbormasterBuildableInterface $object) {
|
|
|
|
$this->object = $object;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
final public function getObject() {
|
|
|
|
return $this->object;
|
|
|
|
}
|
|
|
|
|
2018-04-03 16:25:10 +02:00
|
|
|
protected function getPublishableObject() {
|
|
|
|
return $this->getObject();
|
|
|
|
}
|
|
|
|
|
2018-04-03 15:41:00 +02:00
|
|
|
public function publishBuildable(
|
2018-04-03 14:48:40 +02:00
|
|
|
HarbormasterBuildable $old,
|
|
|
|
HarbormasterBuildable $new) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
final public static function newForObject(
|
|
|
|
HarbormasterBuildableInterface $object,
|
|
|
|
PhabricatorUser $viewer) {
|
|
|
|
return $object->newBuildableEngine()
|
|
|
|
->setViewer($viewer)
|
|
|
|
->setObject($object);
|
|
|
|
}
|
|
|
|
|
|
|
|
final protected function newEditor() {
|
2018-04-03 16:25:10 +02:00
|
|
|
$publishable = $this->getPublishableObject();
|
2018-04-03 14:48:40 +02:00
|
|
|
|
|
|
|
$viewer = $this->getViewer();
|
|
|
|
|
|
|
|
$editor = $publishable->getApplicationTransactionEditor()
|
|
|
|
->setActor($viewer)
|
|
|
|
->setContinueOnNoEffect(true)
|
|
|
|
->setContinueOnMissingFields(true);
|
|
|
|
|
|
|
|
$acting_as_phid = $this->getActingAsPHID();
|
|
|
|
if ($acting_as_phid !== null) {
|
|
|
|
$editor->setActingAsPHID($acting_as_phid);
|
|
|
|
}
|
|
|
|
|
|
|
|
$content_source = $this->getContentSource();
|
|
|
|
if ($content_source !== null) {
|
|
|
|
$editor->setContentSource($content_source);
|
|
|
|
}
|
|
|
|
|
|
|
|
return $editor;
|
|
|
|
}
|
|
|
|
|
|
|
|
final protected function newTransaction() {
|
2018-04-03 16:25:10 +02:00
|
|
|
$publishable = $this->getPublishableObject();
|
2018-04-03 14:48:40 +02:00
|
|
|
|
|
|
|
return $publishable->getApplicationTransactionTemplate();
|
|
|
|
}
|
|
|
|
|
|
|
|
final protected function applyTransactions(array $xactions) {
|
2018-04-03 16:25:10 +02:00
|
|
|
$publishable = $this->getPublishableObject();
|
2018-04-03 14:48:40 +02:00
|
|
|
$editor = $this->newEditor();
|
|
|
|
|
2018-12-20 19:41:01 +01:00
|
|
|
$editor->applyTransactions($publishable, $xactions);
|
2018-04-03 14:48:40 +02:00
|
|
|
}
|
|
|
|
|
2018-08-27 21:46:03 +02:00
|
|
|
public function getAuthorIdentity() {
|
|
|
|
return null;
|
|
|
|
}
|
2018-04-03 14:48:40 +02:00
|
|
|
|
|
|
|
}
|