forked from phacility/phabricator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPHUIDiffInlineCommentPreviewListView.php
66 lines (52 loc) · 1.57 KB
/
PHUIDiffInlineCommentPreviewListView.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
<?php
final class PHUIDiffInlineCommentPreviewListView
extends AphrontView {
private $inlineComments = array();
private $ownerPHID;
public function setInlineComments(array $comments) {
assert_instances_of($comments, 'PhabricatorApplicationTransactionComment');
$this->inlineComments = $comments;
return $this;
}
public function getInlineComments() {
return $this->inlineComments;
}
public function setOwnerPHID($owner_phid) {
$this->ownerPHID = $owner_phid;
return $this;
}
public function getOwnerPHID() {
return $this->ownerPHID;
}
public function render() {
$viewer = $this->getViewer();
$inlines = $this->getInlineComments();
foreach ($inlines as $key => $inline) {
$inlines[$key] = $inline->newInlineCommentObject();
}
$engine = new PhabricatorMarkupEngine();
$engine->setViewer($viewer);
foreach ($inlines as $inline) {
$engine->addObject(
$inline,
PhabricatorInlineComment::MARKUP_FIELD_BODY);
}
$engine->process();
$owner_phid = $this->getOwnerPHID();
$handles = $viewer->loadHandles(array($viewer->getPHID()));
$handles = iterator_to_array($handles);
$views = array();
foreach ($inlines as $inline) {
$views[] = id(new PHUIDiffInlineCommentDetailView())
->setUser($viewer)
->setInlineComment($inline)
->setMarkupEngine($engine)
->setHandles($handles)
->setEditable(false)
->setPreview(true)
->setCanMarkDone(false)
->setObjectOwnerPHID($owner_phid);
}
return $views;
}
}