Differential D19918 Diff 47559 src/applications/transactions/response/PhabricatorApplicationTransactionResponse.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/transactions/response/PhabricatorApplicationTransactionResponse.php
<?php | <?php | ||||
final class PhabricatorApplicationTransactionResponse | final class PhabricatorApplicationTransactionResponse | ||||
extends AphrontProxyResponse { | extends AphrontProxyResponse { | ||||
private $viewer; | private $viewer; | ||||
private $transactions; | private $transactions; | ||||
private $isPreview; | private $isPreview; | ||||
private $transactionView; | |||||
private $previewContent; | private $previewContent; | ||||
private $object; | |||||
public function setTransactionView($transaction_view) { | |||||
$this->transactionView = $transaction_view; | |||||
return $this; | |||||
} | |||||
public function getTransactionView() { | |||||
return $this->transactionView; | |||||
} | |||||
protected function buildProxy() { | protected function buildProxy() { | ||||
return new AphrontAjaxResponse(); | return new AphrontAjaxResponse(); | ||||
} | } | ||||
public function setTransactions($transactions) { | public function setTransactions($transactions) { | ||||
assert_instances_of($transactions, 'PhabricatorApplicationTransaction'); | assert_instances_of($transactions, 'PhabricatorApplicationTransaction'); | ||||
$this->transactions = $transactions; | $this->transactions = $transactions; | ||||
return $this; | return $this; | ||||
} | } | ||||
public function getTransactions() { | public function getTransactions() { | ||||
return $this->transactions; | return $this->transactions; | ||||
} | } | ||||
public function setObject($object) { | |||||
$this->object = $object; | |||||
return $this; | |||||
} | |||||
public function getObject() { | |||||
return $this->object; | |||||
} | |||||
public function setViewer(PhabricatorUser $viewer) { | public function setViewer(PhabricatorUser $viewer) { | ||||
$this->viewer = $viewer; | $this->viewer = $viewer; | ||||
return $this; | return $this; | ||||
} | } | ||||
public function getViewer() { | public function getViewer() { | ||||
return $this->viewer; | return $this->viewer; | ||||
} | } | ||||
public function setIsPreview($is_preview) { | public function setIsPreview($is_preview) { | ||||
$this->isPreview = $is_preview; | $this->isPreview = $is_preview; | ||||
return $this; | return $this; | ||||
} | } | ||||
public function setPreviewContent($preview_content) { | public function setPreviewContent($preview_content) { | ||||
$this->previewContent = $preview_content; | $this->previewContent = $preview_content; | ||||
return $this; | return $this; | ||||
} | } | ||||
public function getPreviewContent() { | public function getPreviewContent() { | ||||
return $this->previewContent; | return $this->previewContent; | ||||
} | } | ||||
public function reduceProxyResponse() { | public function reduceProxyResponse() { | ||||
if ($this->transactionView) { | $object = $this->getObject(); | ||||
$view = $this->transactionView; | $viewer = $this->getViewer(); | ||||
} else if ($this->getTransactions()) { | $xactions = $this->getTransactions(); | ||||
$view = head($this->getTransactions()) | |||||
->getApplicationTransactionViewObject(); | $timeline_engine = PhabricatorTimelineEngine::newForObject($object) | ||||
} else { | ->setViewer($viewer) | ||||
$view = new PhabricatorApplicationTransactionView(); | ->setTransactions($xactions); | ||||
} | |||||
$view = $timeline_engine->buildTimelineView(); | |||||
$view | $view->setIsPreview($this->isPreview); | ||||
->setUser($this->getViewer()) | |||||
->setTransactions($this->getTransactions()) | |||||
->setIsPreview($this->isPreview); | |||||
if ($this->isPreview) { | if ($this->isPreview) { | ||||
$xactions = mpull($view->buildEvents(), 'render'); | $xactions = mpull($view->buildEvents(), 'render'); | ||||
} else { | } else { | ||||
$xactions = mpull($view->buildEvents(), 'render', 'getTransactionPHID'); | $xactions = mpull($view->buildEvents(), 'render', 'getTransactionPHID'); | ||||
} | } | ||||
// Force whatever the underlying views built to render into HTML for | // Force whatever the underlying views built to render into HTML for | ||||
Show All 24 Lines |