Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F96196630
DifferentialReviewersField.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 23, 16:28
Size
2 KB
Mime Type
text/x-php
Expires
Wed, Dec 25, 16:28 (1 d, 23 h)
Engine
blob
Format
Raw Data
Handle
23142518
Attached To
rPH Phabricator
DifferentialReviewersField.php
View Options
<?php
final
class
DifferentialReviewersField
extends
DifferentialCoreCustomField
{
public
function
getFieldKey
()
{
return
'differential:reviewers'
;
}
public
function
getFieldName
()
{
return
pht
(
'Reviewers'
);
}
public
function
getFieldDescription
()
{
return
pht
(
'Manage reviewers.'
);
}
protected
function
readValueFromRevision
(
DifferentialRevision
$revision
)
{
return
$revision
->
getReviewerStatus
();
}
public
function
shouldAppearInPropertyView
()
{
return
true
;
}
public
function
renderPropertyViewLabel
()
{
return
$this
->
getFieldName
();
}
public
function
getRequiredHandlePHIDsForPropertyView
()
{
return
mpull
(
$this
->
getUserReviewers
(),
'getReviewerPHID'
);
}
public
function
renderPropertyViewValue
(
array
$handles
)
{
$reviewers
=
$this
->
getUserReviewers
();
if
(!
$reviewers
)
{
return
phutil_tag
(
'em'
,
array
(),
pht
(
'None'
));
}
$view
=
id
(
new
DifferentialReviewersView
())
->
setUser
(
$this
->
getViewer
())
->
setReviewers
(
$reviewers
)
->
setHandles
(
$handles
);
// TODO: Active diff stuff.
return
$view
;
}
private
function
getUserReviewers
()
{
$reviewers
=
array
();
foreach
(
$this
->
getObject
()->
getReviewerStatus
()
as
$reviewer
)
{
if
(
$reviewer
->
isUser
())
{
$reviewers
[]
=
$reviewer
;
}
}
return
$reviewers
;
}
public
function
getRequiredHandlePHIDsForRevisionHeaderWarnings
()
{
return
mpull
(
$this
->
getValue
(),
'getReviewerPHID'
);
}
public
function
getWarningsForRevisionHeader
(
array
$handles
)
{
$revision
=
$this
->
getObject
();
$status_needs_review
=
ArcanistDifferentialRevisionStatus
::
NEEDS_REVIEW
;
if
(
$revision
->
getStatus
()
!=
$status_needs_review
)
{
return
array
();
}
foreach
(
$this
->
getValue
()
as
$reviewer
)
{
if
(!
$handles
[
$reviewer
->
getReviewerPHID
()]->
isDisabled
())
{
return
array
();
}
}
$warnings
=
array
();
if
(
$this
->
getValue
())
{
$warnings
[]
=
pht
(
'This revision needs review, but all specified reviewers are '
.
'disabled or inactive.'
);
}
else
{
$warnings
[]
=
pht
(
'This revision needs review, but there are no reviewers specified.'
);
}
return
$warnings
;
}
}
Event Timeline
Log In to Comment