@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
at upstream/main 70 lines 1.7 kB view raw
1<?php 2 3final class PHUIDiffInlineCommentPreviewListView 4 extends AphrontView { 5 6 private $inlineComments = array(); 7 private $ownerPHID; 8 9 /** 10 * @param array<PhabricatorApplicationTransactionComment> $comments 11 */ 12 public function setInlineComments(array $comments) { 13 assert_instances_of($comments, 14 PhabricatorApplicationTransactionComment::class); 15 $this->inlineComments = $comments; 16 return $this; 17 } 18 19 public function getInlineComments() { 20 return $this->inlineComments; 21 } 22 23 public function setOwnerPHID($owner_phid) { 24 $this->ownerPHID = $owner_phid; 25 return $this; 26 } 27 28 public function getOwnerPHID() { 29 return $this->ownerPHID; 30 } 31 32 public function render() { 33 $viewer = $this->getViewer(); 34 35 $inlines = $this->getInlineComments(); 36 foreach ($inlines as $key => $inline) { 37 $inlines[$key] = $inline->newInlineCommentObject(); 38 } 39 40 $engine = new PhabricatorMarkupEngine(); 41 $engine->setViewer($viewer); 42 foreach ($inlines as $inline) { 43 $engine->addObject( 44 $inline, 45 PhabricatorInlineComment::MARKUP_FIELD_BODY); 46 } 47 $engine->process(); 48 49 $owner_phid = $this->getOwnerPHID(); 50 51 $handles = $viewer->loadHandles(array($viewer->getPHID())); 52 $handles = iterator_to_array($handles); 53 54 $views = array(); 55 foreach ($inlines as $inline) { 56 $views[] = id(new PHUIDiffInlineCommentDetailView()) 57 ->setUser($viewer) 58 ->setInlineComment($inline) 59 ->setMarkupEngine($engine) 60 ->setHandles($handles) 61 ->setEditable(false) 62 ->setPreview(true) 63 ->setCanMarkDone(false) 64 ->setObjectOwnerPHID($owner_phid); 65 } 66 67 return $views; 68 } 69 70}