Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F96783203
ConduitAPI_differential_getrevisioncomments_Method.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Mon, Dec 30, 19:51
Size
2 KB
Mime Type
text/x-php
Expires
Wed, Jan 1, 19:51 (1 d, 23 h)
Engine
blob
Format
Raw Data
Handle
23260052
Attached To
rPH Phabricator
ConduitAPI_differential_getrevisioncomments_Method.php
View Options
<?php
/**
* @group conduit
*/
final
class
ConduitAPI_differential_getrevisioncomments_Method
extends
ConduitAPI_differential_Method
{
public
function
getMethodDescription
()
{
return
"Retrieve Differential Revision Comments."
;
}
public
function
defineParamTypes
()
{
return
array
(
'ids'
=>
'required list<int>'
,
'inlines'
=>
'optional bool'
,
);
}
public
function
defineReturnType
()
{
return
'nonempty list<dict<string, wild>>'
;
}
public
function
defineErrorTypes
()
{
return
array
(
);
}
protected
function
execute
(
ConduitAPIRequest
$request
)
{
$results
=
array
();
$revision_ids
=
$request
->
getValue
(
'ids'
);
if
(!
$revision_ids
)
{
return
$results
;
}
$comments
=
id
(
new
DifferentialCommentQuery
())
->
withRevisionIDs
(
$revision_ids
)
->
execute
();
$with_inlines
=
$request
->
getValue
(
'inlines'
);
if
(
$with_inlines
)
{
$inlines
=
id
(
new
DifferentialInlineComment
())->
loadAllWhere
(
'revisionID IN (%Ld)'
,
$revision_ids
);
$changesets
=
array
();
if
(
$inlines
)
{
$changesets
=
id
(
new
DifferentialChangeset
())->
loadAllWhere
(
'id IN (%Ld)'
,
array_unique
(
mpull
(
$inlines
,
'getChangesetID'
)));
$inlines
=
mgroup
(
$inlines
,
'getCommentID'
);
}
}
foreach
(
$comments
as
$comment
)
{
$revision_id
=
$comment
->
getRevisionID
();
$result
=
array
(
'revisionID'
=>
$revision_id
,
'action'
=>
$comment
->
getAction
(),
'authorPHID'
=>
$comment
->
getAuthorPHID
(),
'dateCreated'
=>
$comment
->
getDateCreated
(),
'content'
=>
$comment
->
getContent
(),
);
if
(
$with_inlines
)
{
$result
[
'inlines'
]
=
array
();
foreach
(
idx
(
$inlines
,
$comment
->
getID
(),
array
())
as
$inline
)
{
$changeset
=
idx
(
$changesets
,
$inline
->
getChangesetID
());
$result
[
'inlines'
][]
=
$this
->
buildInlineInfoDictionary
(
$inline
,
$changeset
);
}
// TODO: Put synthetic inlines without an attached comment somewhere.
}
$results
[
$revision_id
][]
=
$result
;
}
return
$results
;
}
}
Event Timeline
Log In to Comment