2012-12-11 23:02:29 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
final class PhabricatorApplicationTransactionResponse
|
|
|
|
extends AphrontProxyResponse {
|
|
|
|
|
|
|
|
private $viewer;
|
|
|
|
private $transactions;
|
|
|
|
private $anchorOffset;
|
2012-12-21 14:51:33 +01:00
|
|
|
private $isPreview;
|
2012-12-11 23:02:29 +01:00
|
|
|
|
|
|
|
protected function buildProxy() {
|
|
|
|
return new AphrontAjaxResponse();
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setAnchorOffset($anchor_offset) {
|
|
|
|
$this->anchorOffset = $anchor_offset;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getAnchorOffset() {
|
|
|
|
return $this->anchorOffset;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setTransactions($transactions) {
|
|
|
|
assert_instances_of($transactions, 'PhabricatorApplicationTransaction');
|
|
|
|
|
|
|
|
$this->transactions = $transactions;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getTransactions() {
|
|
|
|
return $this->transactions;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setViewer(PhabricatorUser $viewer) {
|
|
|
|
$this->viewer = $viewer;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getViewer() {
|
|
|
|
return $this->viewer;
|
|
|
|
}
|
|
|
|
|
2012-12-21 14:51:33 +01:00
|
|
|
public function setIsPreview($is_preview) {
|
|
|
|
$this->isPreview = $is_preview;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
2012-12-12 02:27:25 +01:00
|
|
|
public function reduceProxyResponse() {
|
2012-12-11 23:02:29 +01:00
|
|
|
$view = id(new PhabricatorApplicationTransactionView())
|
2012-12-21 14:51:33 +01:00
|
|
|
->setUser($this->getViewer())
|
|
|
|
->setTransactions($this->getTransactions())
|
|
|
|
->setIsPreview($this->isPreview);
|
2012-12-11 23:02:29 +01:00
|
|
|
|
|
|
|
if ($this->getAnchorOffset()) {
|
|
|
|
$view->setAnchorOffset($this->getAnchorOffset());
|
|
|
|
}
|
|
|
|
|
2012-12-21 14:51:33 +01:00
|
|
|
if ($this->isPreview) {
|
|
|
|
$xactions = mpull($view->buildEvents(), 'render');
|
|
|
|
} else {
|
|
|
|
$xactions = mpull($view->buildEvents(), 'render', 'getTransactionPHID');
|
|
|
|
}
|
2012-12-11 23:02:29 +01:00
|
|
|
|
|
|
|
$content = array(
|
|
|
|
'xactions' => $xactions,
|
|
|
|
'spacer' => PhabricatorTimelineView::renderSpacer(),
|
|
|
|
);
|
|
|
|
|
2012-12-12 02:27:25 +01:00
|
|
|
return $this->getProxy()->setContent($content);
|
2012-12-11 23:02:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|