Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F539160
PhabricatorDashboardQueryPanelQueryEditField.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
PhabricatorDashboardQueryPanelQueryEditField.php
View Options
<?php
final
class
PhabricatorDashboardQueryPanelQueryEditField
extends
PhabricatorEditField
{
private
$applicationControlID
;
public
function
setApplicationControlID
(
$id
)
{
$this
->
applicationControlID
=
$id
;
return
$this
;
}
public
function
getApplicationControlID
()
{
return
$this
->
applicationControlID
;
}
protected
function
newControl
()
{
$engines
=
id
(
new
PhutilClassMapQuery
())
->
setAncestorClass
(
'PhabricatorApplicationSearchEngine'
)
->
setFilterMethod
(
'canUseInPanelContext'
)
->
execute
();
$value
=
$this
->
getValueForControl
();
$queries
=
array
();
$seen
=
false
;
foreach
(
$engines
as
$engine_class
=>
$engine
)
{
$engine
->
setViewer
(
$this
->
getViewer
());
$engine_queries
=
$engine
->
loadEnabledNamedQueries
();
$query_map
=
mpull
(
$engine_queries
,
'getQueryName'
,
'getQueryKey'
);
asort
(
$query_map
);
foreach
(
$query_map
as
$key
=>
$name
)
{
$queries
[
$engine_class
][]
=
array
(
'key'
=>
$key
,
'name'
=>
$name
);
if
(
$key
==
$value
)
{
$seen
=
true
;
}
}
}
if
(
phutil_nonempty_string
(
$value
)
&&
!
$seen
)
{
$name
=
pht
(
'Custom Query ("%s")'
,
$value
);
}
else
{
$name
=
pht
(
'(None)'
);
}
$options
=
array
(
$value
=>
$name
);
$application_id
=
$this
->
getApplicationControlID
();
$control_id
=
celerity_generate_unique_node_id
();
Javelin
::
initBehavior
(
'dashboard-query-panel-select'
,
array
(
'applicationID'
=>
$application_id
,
'queryID'
=>
$control_id
,
'options'
=>
$queries
,
'value'
=>
array
(
'key'
=>
phutil_nonempty_string
(
$value
)
?
$value
:
null
,
'name'
=>
$name
,
),
));
return
id
(
new
AphrontFormSelectControl
())
->
setID
(
$control_id
)
->
setOptions
(
$options
);
}
protected
function
newHTTPParameterType
()
{
return
new
AphrontSelectHTTPParameterType
();
}
protected
function
newConduitParameterType
()
{
return
new
ConduitStringParameterType
();
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Mon, May 12, 9:05 AM (1 d, 18 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
103677
Default Alt Text
PhabricatorDashboardQueryPanelQueryEditField.php (1 KB)
Attached To
Mode
rP Phorge
Attached
Detach File
Event Timeline
Log In to Comment