Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F70426778
DifferentialResponsibleViewerFunctionDatasource.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 6, 19:56
Size
1 KB
Mime Type
text/x-php
Expires
Mon, Jul 8, 19:56 (2 d)
Engine
blob
Format
Raw Data
Handle
18840528
Attached To
rPH Phabricator
DifferentialResponsibleViewerFunctionDatasource.php
View Options
<?php
final
class
DifferentialResponsibleViewerFunctionDatasource
extends
PhabricatorTypeaheadDatasource
{
public
function
getBrowseTitle
()
{
return
pht
(
'Browse Viewer'
);
}
public
function
getPlaceholderText
()
{
return
pht
(
'Type viewer()...'
);
}
public
function
getDatasourceApplicationClass
()
{
return
'PhabricatorPeopleApplication'
;
}
public
function
getDatasourceFunctions
()
{
return
array
(
'viewer'
=>
array
(
'name'
=>
pht
(
'Current Viewer'
),
'summary'
=>
pht
(
'Use the current viewing user.'
),
'description'
=>
pht
(
'Show revisions the current viewer is responsible for. This '
.
'function inclues revisions the viewer is responsible for through '
.
'membership in projects and packages.'
),
),
);
}
public
function
loadResults
()
{
if
(
$this
->
getViewer
()->
getPHID
())
{
$results
=
array
(
$this
->
renderViewerFunctionToken
());
}
else
{
$results
=
array
();
}
return
$this
->
filterResultsAgainstTokens
(
$results
);
}
protected
function
canEvaluateFunction
(
$function
)
{
if
(!
$this
->
getViewer
()->
getPHID
())
{
return
false
;
}
return
parent
::
canEvaluateFunction
(
$function
);
}
protected
function
evaluateFunction
(
$function
,
array
$argv_list
)
{
$results
=
array
();
foreach
(
$argv_list
as
$argv
)
{
$results
[]
=
$this
->
getViewer
()->
getPHID
();
}
return
DifferentialResponsibleDatasource
::
expandResponsibleUsers
(
$this
->
getViewer
(),
$results
);
}
public
function
renderFunctionTokens
(
$function
,
array
$argv_list
)
{
$tokens
=
array
();
foreach
(
$argv_list
as
$argv
)
{
$tokens
[]
=
PhabricatorTypeaheadTokenView
::
newFromTypeaheadResult
(
$this
->
renderViewerFunctionToken
());
}
return
$tokens
;
}
private
function
renderViewerFunctionToken
()
{
return
$this
->
newFunctionResult
()
->
setName
(
pht
(
'Current Viewer'
))
->
setPHID
(
'viewer()'
)
->
setIcon
(
'fa-user'
)
->
setUnique
(
true
);
}
}
Event Timeline
Log In to Comment