Differential D12033 Diff 29183 src/infrastructure/diff/PhabricatorInlineCommentPreviewController.php
Changeset View
Changeset View
Standalone View
Standalone View
src/infrastructure/diff/PhabricatorInlineCommentPreviewController.php
<?php | <?php | ||||
abstract class PhabricatorInlineCommentPreviewController | abstract class PhabricatorInlineCommentPreviewController | ||||
extends PhabricatorController { | extends PhabricatorController { | ||||
abstract protected function loadInlineComments(); | abstract protected function loadInlineComments(); | ||||
public function processRequest() { | public function processRequest() { | ||||
$request = $this->getRequest(); | $request = $this->getRequest(); | ||||
$user = $request->getUser(); | $viewer = $request->getUser(); | ||||
$inlines = $this->loadInlineComments(); | $inlines = $this->loadInlineComments(); | ||||
assert_instances_of($inlines, 'PhabricatorInlineCommentInterface'); | assert_instances_of($inlines, 'PhabricatorInlineCommentInterface'); | ||||
$engine = new PhabricatorMarkupEngine(); | $engine = new PhabricatorMarkupEngine(); | ||||
$engine->setViewer($user); | $engine->setViewer($viewer); | ||||
foreach ($inlines as $inline) { | foreach ($inlines as $inline) { | ||||
$engine->addObject( | $engine->addObject( | ||||
$inline, | $inline, | ||||
PhabricatorInlineCommentInterface::MARKUP_FIELD_BODY); | PhabricatorInlineCommentInterface::MARKUP_FIELD_BODY); | ||||
} | } | ||||
$engine->process(); | $engine->process(); | ||||
$phids = array($user->getPHID()); | $phids = array($viewer->getPHID()); | ||||
$handles = $this->loadViewerHandles($phids); | $handles = $this->loadViewerHandles($phids); | ||||
$views = array(); | $views = array(); | ||||
foreach ($inlines as $inline) { | foreach ($inlines as $inline) { | ||||
$view = new PHUIDiffInlineCommentDetailView(); | $view = id(new PHUIDiffInlineCommentDetailView()) | ||||
$view->setInlineComment($inline); | ->setInlineComment($inline) | ||||
$view->setMarkupEngine($engine); | ->setMarkupEngine($engine) | ||||
$view->setHandles($handles); | ->setHandles($handles) | ||||
$view->setEditable(false); | ->setEditable(false) | ||||
$view->setPreview(true); | ->setPreview(true) | ||||
->setCanMarkDone(false); | |||||
$views[] = $view->render(); | $views[] = $view->render(); | ||||
} | } | ||||
$views = phutil_implode_html("\n", $views); | $views = phutil_implode_html("\n", $views); | ||||
return id(new AphrontAjaxResponse()) | return id(new AphrontAjaxResponse()) | ||||
->setContent($views); | ->setContent($views); | ||||
} | } | ||||
} | } |