Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F545716
PhabricatorSearchNameController.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
PhabricatorSearchNameController.php
View Options
<?php
/**
* @group search
*/
final
class
PhabricatorSearchNameController
extends
PhabricatorSearchBaseController
{
private
$queryKey
;
public
function
willProcessRequest
(
array
$data
)
{
$this
->
queryKey
=
idx
(
$data
,
'queryKey'
);
}
public
function
processRequest
()
{
$request
=
$this
->
getRequest
();
$user
=
$request
->
getUser
();
if
(
$this
->
queryKey
)
{
$saved_query
=
id
(
new
PhabricatorSavedQueryQuery
())
->
setViewer
(
$user
)
->
withQueryKeys
(
array
(
$this
->
queryKey
))
->
executeOne
();
if
(!
$saved_query
)
{
return
new
Aphront404Response
();
}
}
else
{
return
new
Aphront404Response
();
}
if
(
$request
->
isFormPost
())
{
$named_query
=
id
(
new
PhabricatorNamedQuery
())
->
setUserPHID
(
$user
->
getPHID
())
->
setQueryKey
(
$saved_query
->
getQueryKey
())
->
setQueryName
(
$request
->
getStr
(
'name'
))
->
setEngineClassName
(
$saved_query
->
getEngineClassName
());
try
{
$named_query
->
save
();
}
catch
(
AphrontQueryDuplicateKeyException
$ex
)
{
// Ignore, the user is naming an identical query.
}
return
id
(
new
AphrontRedirectResponse
())
->
setURI
(
'/search/'
);
}
$form
=
id
(
new
AphrontFormView
())
->
setUser
(
$user
);
$form
->
appendChild
(
id
(
new
AphrontFormTextControl
())
->
setName
(
'name'
)
->
setLabel
(
pht
(
'Query Name'
)));
$form
->
appendChild
(
id
(
new
AphrontFormSubmitControl
())
->
setValue
(
pht
(
'Save'
)));
return
$this
->
buildStandardPageResponse
(
array
(
$form
,
),
array
(
'title'
=>
'Name Query'
,
));
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Mon, May 12, 12:58 PM (2 d)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
122475
Default Alt Text
PhabricatorSearchNameController.php (1 KB)
Attached To
Mode
rP Phorge
Attached
Detach File
Event Timeline
Log In to Comment