Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F93528517
PhabricatorOAuthServerClientSearchEngine.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, 11:50
Size
2 KB
Mime Type
text/x-php
Expires
Sun, Dec 1, 11:50 (1 d, 23 h)
Engine
blob
Format
Raw Data
Handle
22660183
Attached To
rPH Phabricator
PhabricatorOAuthServerClientSearchEngine.php
View Options
<?php
final
class
PhabricatorOAuthServerClientSearchEngine
extends
PhabricatorApplicationSearchEngine
{
public
function
getResultTypeDescription
()
{
return
pht
(
'OAuth Clients'
);
}
public
function
getApplicationClassName
()
{
return
'PhabricatorApplicationOAuthServer'
;
}
public
function
buildSavedQueryFromRequest
(
AphrontRequest
$request
)
{
$saved
=
new
PhabricatorSavedQuery
();
$saved
->
setParameter
(
'creatorPHIDs'
,
$this
->
readUsersFromRequest
(
$request
,
'creators'
));
return
$saved
;
}
public
function
buildQueryFromSavedQuery
(
PhabricatorSavedQuery
$saved
)
{
$query
=
id
(
new
PhabricatorOAuthServerClientQuery
());
$creator_phids
=
$saved
->
getParameter
(
'creatorPHIDs'
,
array
());
if
(
$creator_phids
)
{
$query
->
withCreatorPHIDs
(
$saved
->
getParameter
(
'creatorPHIDs'
,
array
()));
}
return
$query
;
}
public
function
buildSearchForm
(
AphrontFormView
$form
,
PhabricatorSavedQuery
$saved_query
)
{
$phids
=
$saved_query
->
getParameter
(
'creatorPHIDs'
,
array
());
$creator_handles
=
id
(
new
PhabricatorHandleQuery
())
->
setViewer
(
$this
->
requireViewer
())
->
withPHIDs
(
$phids
)
->
execute
();
$form
->
appendChild
(
id
(
new
AphrontFormTokenizerControl
())
->
setDatasource
(
new
PhabricatorPeopleDatasource
())
->
setName
(
'creators'
)
->
setLabel
(
pht
(
'Creators'
))
->
setValue
(
$creator_handles
));
}
protected
function
getURI
(
$path
)
{
return
'/oauthserver/'
.
$path
;
}
public
function
getBuiltinQueryNames
()
{
$names
=
array
();
if
(
$this
->
requireViewer
()->
isLoggedIn
())
{
$names
[
'created'
]
=
pht
(
'Created'
);
}
$names
[
'all'
]
=
pht
(
'All Applications'
);
return
$names
;
}
public
function
buildSavedQueryFromBuiltin
(
$query_key
)
{
$query
=
$this
->
newSavedQuery
();
$query
->
setQueryKey
(
$query_key
);
switch
(
$query_key
)
{
case
'all'
:
return
$query
;
case
'created'
:
return
$query
->
setParameter
(
'creatorPHIDs'
,
array
(
$this
->
requireViewer
()->
getPHID
()));
}
return
parent
::
buildSavedQueryFromBuiltin
(
$query_key
);
}
protected
function
getRequiredHandlePHIDsForResultList
(
array
$clients
,
PhabricatorSavedQuery
$query
)
{
return
mpull
(
$clients
,
'getCreatorPHID'
);
}
protected
function
renderResultList
(
array
$clients
,
PhabricatorSavedQuery
$query
,
array
$handles
)
{
assert_instances_of
(
$clients
,
'PhabricatorOauthServerClient'
);
$viewer
=
$this
->
requireViewer
();
$list
=
id
(
new
PHUIObjectItemListView
())
->
setUser
(
$viewer
);
foreach
(
$clients
as
$client
)
{
$creator
=
$handles
[
$client
->
getCreatorPHID
()];
$item
=
id
(
new
PHUIObjectItemView
())
->
setObjectName
(
pht
(
'Application %d'
,
$client
->
getID
()))
->
setHeader
(
$client
->
getName
())
->
setHref
(
$client
->
getViewURI
())
->
setObject
(
$client
)
->
addByline
(
pht
(
'Creator: %s'
,
$creator
->
renderLink
()));
$list
->
addItem
(
$item
);
}
return
$list
;
}
}
Event Timeline
Log In to Comment