Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F80950981
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
Tue, Sep 3, 10:23
Size
2 KB
Mime Type
text/x-php
Expires
Thu, Sep 5, 10:23 (2 d)
Engine
blob
Format
Raw Data
Handle
20481986
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
DifferentialInlineCommentQuery
())
->
withRevisionIDs
(
$revision_ids
)
->
execute
();
$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