Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F120545239
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
Sat, Jul 5, 03:24
Size
2 KB
Mime Type
text/x-php
Expires
Mon, Jul 7, 03:24 (2 d)
Engine
blob
Format
Raw Data
Handle
27204669
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
)
{
// TODO: Sort this out in the ID -> PHID change.
$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