Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F475919
HeraldWebhookSearchEngine.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
2 KB
Referenced Files
None
Subscribers
None
HeraldWebhookSearchEngine.php
View Options
<?php
final
class
HeraldWebhookSearchEngine
extends
PhabricatorApplicationSearchEngine
{
public
function
getResultTypeDescription
()
{
return
pht
(
'Webhooks'
);
}
public
function
getApplicationClassName
()
{
return
PhabricatorHeraldApplication
::
class
;
}
public
function
newQuery
()
{
return
new
HeraldWebhookQuery
();
}
protected
function
buildQueryFromParameters
(
array
$map
)
{
$query
=
$this
->
newQuery
();
if
(
$map
[
'statuses'
])
{
$query
->
withStatuses
(
$map
[
'statuses'
]);
}
return
$query
;
}
protected
function
buildCustomSearchFields
()
{
return
array
(
id
(
new
PhabricatorSearchCheckboxesField
())
->
setKey
(
'statuses'
)
->
setLabel
(
pht
(
'Status'
))
->
setDescription
(
pht
(
'Search for archived or active pastes.'
))
->
setOptions
(
HeraldWebhook
::
getStatusDisplayNameMap
()),
);
}
protected
function
getURI
(
$path
)
{
return
'/herald/webhook/'
.
$path
;
}
protected
function
getBuiltinQueryNames
()
{
$names
=
array
();
$names
[
'active'
]
=
pht
(
'Active'
);
$names
[
'all'
]
=
pht
(
'All'
);
return
$names
;
}
public
function
buildSavedQueryFromBuiltin
(
$query_key
)
{
$query
=
$this
->
newSavedQuery
();
$query
->
setQueryKey
(
$query_key
);
switch
(
$query_key
)
{
case
'all'
:
return
$query
;
case
'active'
:
return
$query
->
setParameter
(
'statuses'
,
array
(
HeraldWebhook
::
HOOKSTATUS_FIREHOSE
,
HeraldWebhook
::
HOOKSTATUS_ENABLED
,
));
}
return
parent
::
buildSavedQueryFromBuiltin
(
$query_key
);
}
protected
function
renderResultList
(
array
$hooks
,
PhabricatorSavedQuery
$query
,
array
$handles
)
{
assert_instances_of
(
$hooks
,
'HeraldWebhook'
);
$viewer
=
$this
->
requireViewer
();
$list
=
id
(
new
PHUIObjectItemListView
())
->
setViewer
(
$viewer
);
foreach
(
$hooks
as
$hook
)
{
$item
=
id
(
new
PHUIObjectItemView
())
->
setObjectName
(
pht
(
'Webhook %d'
,
$hook
->
getID
()))
->
setHeader
(
$hook
->
getName
())
->
setHref
(
$hook
->
getURI
())
->
addAttribute
(
$hook
->
getWebhookURI
());
$item
->
addIcon
(
$hook
->
getStatusIcon
(),
$hook
->
getStatusDisplayName
());
if
(
$hook
->
isDisabled
())
{
$item
->
setDisabled
(
true
);
}
$list
->
addItem
(
$item
);
}
return
id
(
new
PhabricatorApplicationSearchResultView
())
->
setObjectList
(
$list
)
->
setNoDataString
(
pht
(
'No webhooks found.'
));
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Wed, May 7, 1:09 AM (2 d)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
85781
Default Alt Text
HeraldWebhookSearchEngine.php (2 KB)
Attached To
Mode
rP Phorge
Attached
Detach File
Event Timeline
Log In to Comment