Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F93467664
PhabricatorSearchDefaultController.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
Fri, Nov 29, 00:20
Size
2 KB
Mime Type
text/x-php
Expires
Sun, Dec 1, 00:20 (1 d, 23 h)
Engine
blob
Format
Raw Data
Handle
22646674
Attached To
rPH Phabricator
PhabricatorSearchDefaultController.php
View Options
<?php
final
class
PhabricatorSearchDefaultController
extends
PhabricatorSearchBaseController
{
public
function
handleRequest
(
AphrontRequest
$request
)
{
$viewer
=
$this
->
getViewer
();
$engine_class
=
$request
->
getURIData
(
'engine'
);
$base_class
=
'PhabricatorApplicationSearchEngine'
;
if
(!
is_subclass_of
(
$engine_class
,
$base_class
))
{
return
new
Aphront400Response
();
}
$engine
=
newv
(
$engine_class
,
array
());
$engine
->
setViewer
(
$viewer
);
$key
=
$request
->
getURIData
(
'queryKey'
);
$named_query
=
id
(
new
PhabricatorNamedQueryQuery
())
->
setViewer
(
$viewer
)
->
withEngineClassNames
(
array
(
$engine_class
))
->
withQueryKeys
(
array
(
$key
))
->
withUserPHIDs
(
array
(
$viewer
->
getPHID
(),
PhabricatorNamedQuery
::
SCOPE_GLOBAL
,
))
->
executeOne
();
if
(!
$named_query
&&
$engine
->
isBuiltinQuery
(
$key
))
{
$named_query
=
$engine
->
getBuiltinQuery
(
$key
);
}
if
(!
$named_query
)
{
return
new
Aphront404Response
();
}
$return_uri
=
$engine
->
getQueryManagementURI
();
$builtin
=
null
;
if
(
$engine
->
isBuiltinQuery
(
$key
))
{
$builtin
=
$engine
->
getBuiltinQuery
(
$key
);
}
if
(
$request
->
isFormPost
())
{
$config
=
id
(
new
PhabricatorNamedQueryConfigQuery
())
->
setViewer
(
$viewer
)
->
withEngineClassNames
(
array
(
$engine_class
))
->
withScopePHIDs
(
array
(
$viewer
->
getPHID
()))
->
executeOne
();
if
(!
$config
)
{
$config
=
PhabricatorNamedQueryConfig
::
initializeNewQueryConfig
()
->
setEngineClassName
(
$engine_class
)
->
setScopePHID
(
$viewer
->
getPHID
());
}
$config
->
setConfigProperty
(
PhabricatorNamedQueryConfig
::
PROPERTY_PINNED
,
$key
);
$config
->
save
();
return
id
(
new
AphrontRedirectResponse
())->
setURI
(
$return_uri
);
}
if
(
$named_query
->
getIsBuiltin
())
{
$query_name
=
$builtin
->
getQueryName
();
}
else
{
$query_name
=
$named_query
->
getQueryName
();
}
$title
=
pht
(
'Set Default Query'
);
$body
=
pht
(
'This query will become your default query in the current application.'
);
$button
=
pht
(
'Set Default Query'
);
return
$this
->
newDialog
()
->
setTitle
(
$title
)
->
appendChild
(
$body
)
->
addCancelButton
(
$return_uri
)
->
addSubmitButton
(
$button
);
}
}
Event Timeline
Log In to Comment