Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F98041142
PhabricatorSearchManagementQueryWorkflow.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
Thu, Jan 9, 00:05
Size
1 KB
Mime Type
text/x-php
Expires
Sat, Jan 11, 00:05 (2 d)
Engine
blob
Format
Raw Data
Handle
23500625
Attached To
rPH Phabricator
PhabricatorSearchManagementQueryWorkflow.php
View Options
<?php
final
class
PhabricatorSearchManagementQueryWorkflow
extends
PhabricatorSearchManagementWorkflow
{
protected
function
didConstruct
()
{
$this
->
setName
(
'query'
)
->
setSynopsis
(
pht
(
'Run a search query. Intended for debugging and development.'
))
->
setArguments
(
array
(
array
(
'name'
=>
'query'
,
'param'
=>
'query'
,
'help'
=>
pht
(
'Raw query to execute.'
),
),
));
}
public
function
execute
(
PhutilArgumentParser
$args
)
{
$viewer
=
$this
->
getViewer
();
$raw_query
=
$args
->
getArg
(
'query'
);
if
(!
strlen
(
$raw_query
))
{
throw
new
PhutilArgumentUsageException
(
pht
(
'Specify a query with --query.'
));
}
$engine
=
id
(
new
PhabricatorSearchApplicationSearchEngine
())
->
setViewer
(
$viewer
);
$saved
=
$engine
->
newSavedQuery
();
$saved
->
setParameter
(
'query'
,
$raw_query
);
$query
=
$engine
->
buildQueryFromSavedQuery
(
$saved
);
$pager
=
$engine
->
newPagerForSavedQuery
(
$saved
);
$results
=
$engine
->
executeQuery
(
$query
,
$pager
);
if
(
$results
)
{
foreach
(
$results
as
$result
)
{
echo
tsprintf
(
"%s
\t
%s
\n
"
,
$result
->
getPHID
(),
$result
->
getName
());
}
}
else
{
echo
tsprintf
(
"%s
\n
"
,
pht
(
'No results.'
));
}
return
0
;
}
}
Event Timeline
Log In to Comment