Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F2991549
AlmanacNamespaceSearchEngine.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Award Token
Flag For Later
Advanced/Developer...
View Handle
View Hovercard
Size
2 KB
Referenced Files
None
Subscribers
None
AlmanacNamespaceSearchEngine.php
View Options
<?php
final
class
AlmanacNamespaceSearchEngine
extends
PhabricatorApplicationSearchEngine
{
public
function
getResultTypeDescription
(
)
{
return
pht
(
'Almanac Namespaces'
)
;
}
public
function
getApplicationClassName
(
)
{
return
PhabricatorAlmanacApplication
::
class
;
}
public
function
newQuery
(
)
{
return
new
AlmanacNamespaceQuery
(
)
;
}
protected
function
buildCustomSearchFields
(
)
{
return
array
(
id
(
new
PhabricatorSearchTextField
(
)
)
->
setLabel
(
pht
(
'Name Contains'
)
)
->
setKey
(
'match'
)
->
setDescription
(
pht
(
'Search for namespaces by name substring.'
)
)
,
)
;
}
protected
function
buildQueryFromParameters
(
array
$map
)
{
$query
=
$this
->
newQuery
(
)
;
if
(
$map
[
'match'
]
!==
null
)
{
$query
->
withNameNgrams
(
$map
[
'match'
]
)
;
}
return
$query
;
}
protected
function
getURI
(
$path
)
{
return
'/almanac/namespace/'
.
$path
;
}
protected
function
getBuiltinQueryNames
(
)
{
$names
=
array
(
'all'
=>
pht
(
'All Namespaces'
)
,
)
;
return
$names
;
}
public
function
buildSavedQueryFromBuiltin
(
$query_key
)
{
$query
=
$this
->
newSavedQuery
(
)
;
$query
->
setQueryKey
(
$query_key
)
;
switch
(
$query_key
)
{
case
'all'
:
return
$query
;
}
return
parent
::
buildSavedQueryFromBuiltin
(
$query_key
)
;
}
protected
function
renderResultList
(
array
$namespaces
,
PhabricatorSavedQuery
$query
,
array
$handles
)
{
assert_instances_of
(
$namespaces
,
'AlmanacNamespace'
)
;
$viewer
=
$this
->
requireViewer
(
)
;
$list
=
new
PHUIObjectItemListView
(
)
;
$list
->
setUser
(
$viewer
)
;
foreach
(
$namespaces
as
$namespace
)
{
$id
=
$namespace
->
getID
(
)
;
$item
=
id
(
new
PHUIObjectItemView
(
)
)
->
setObjectName
(
pht
(
'Namespace %d'
,
$id
)
)
->
setHeader
(
$namespace
->
getName
(
)
)
->
setHref
(
$this
->
getApplicationURI
(
"namespace/{$id}/"
)
)
->
setObject
(
$namespace
)
;
$list
->
addItem
(
$item
)
;
}
$result
=
new
PhabricatorApplicationSearchResultView
(
)
;
$result
->
setObjectList
(
$list
)
;
$result
->
setNoDataString
(
pht
(
'No Almanac namespaces found.'
)
)
;
return
$result
;
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Sun, Feb 23, 00:59 (1 d, 8 h ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1180844
Default Alt Text
AlmanacNamespaceSearchEngine.php (2 KB)
Attached To
Mode
rP Phorge
Attached
Detach File
Event Timeline
Log In to Comment