Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F96591773
PhabricatorOwnersPackageSearchEngine.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
Sat, Dec 28, 16:09
Size
2 KB
Mime Type
text/x-php
Expires
Mon, Dec 30, 16:09 (2 d)
Engine
blob
Format
Raw Data
Handle
23213444
Attached To
rPH Phabricator
PhabricatorOwnersPackageSearchEngine.php
View Options
<?php
final
class
PhabricatorOwnersPackageSearchEngine
extends
PhabricatorApplicationSearchEngine
{
public
function
getResultTypeDescription
()
{
return
pht
(
'Owners Packages'
);
}
public
function
getApplicationClassName
()
{
return
'PhabricatorOwnersApplication'
;
}
public
function
newQuery
()
{
return
new
PhabricatorOwnersPackageQuery
();
}
protected
function
buildCustomSearchFields
()
{
return
array
(
id
(
new
PhabricatorSearchDatasourceField
())
->
setLabel
(
pht
(
'Authority'
))
->
setKey
(
'authorityPHIDs'
)
->
setAliases
(
array
(
'authority'
,
'authorities'
))
->
setDatasource
(
new
PhabricatorProjectOrUserDatasource
()),
id
(
new
PhabricatorSearchDatasourceField
())
->
setLabel
(
pht
(
'Repositories'
))
->
setKey
(
'repositoryPHIDs'
)
->
setAliases
(
array
(
'repository'
,
'repositories'
))
->
setDatasource
(
new
DiffusionRepositoryDatasource
()),
id
(
new
PhabricatorSearchStringListField
())
->
setLabel
(
pht
(
'Paths'
))
->
setKey
(
'paths'
)
->
setAliases
(
array
(
'path'
)),
);
}
protected
function
buildQueryFromParameters
(
array
$map
)
{
$query
=
$this
->
newQuery
();
if
(
$map
[
'authorityPHIDs'
])
{
$query
->
withAuthorityPHIDs
(
$map
[
'authorityPHIDs'
]);
}
if
(
$map
[
'repositoryPHIDs'
])
{
$query
->
withRepositoryPHIDs
(
$map
[
'repositoryPHIDs'
]);
}
if
(
$map
[
'paths'
])
{
$query
->
withPaths
(
$map
[
'paths'
]);
}
return
$query
;
}
protected
function
getURI
(
$path
)
{
return
'/owners/'
.
$path
;
}
protected
function
getBuiltinQueryNames
()
{
$names
=
array
();
if
(
$this
->
requireViewer
()->
isLoggedIn
())
{
$names
[
'authority'
]
=
pht
(
'Owned'
);
}
$names
+=
array
(
'all'
=>
pht
(
'All Packages'
),
);
return
$names
;
}
public
function
buildSavedQueryFromBuiltin
(
$query_key
)
{
$query
=
$this
->
newSavedQuery
();
$query
->
setQueryKey
(
$query_key
);
switch
(
$query_key
)
{
case
'all'
:
return
$query
;
case
'authority'
:
return
$query
->
setParameter
(
'authorityPHIDs'
,
array
(
$this
->
requireViewer
()->
getPHID
()));
}
return
parent
::
buildSavedQueryFromBuiltin
(
$query_key
);
}
protected
function
renderResultList
(
array
$packages
,
PhabricatorSavedQuery
$query
,
array
$handles
)
{
assert_instances_of
(
$packages
,
'PhabricatorOwnersPackage'
);
$viewer
=
$this
->
requireViewer
();
$list
=
id
(
new
PHUIObjectItemListView
())
->
setUser
(
$viewer
);
foreach
(
$packages
as
$package
)
{
$id
=
$package
->
getID
();
$item
=
id
(
new
PHUIObjectItemView
())
->
setObject
(
$package
)
->
setObjectName
(
pht
(
'Package %d'
,
$id
))
->
setHeader
(
$package
->
getName
())
->
setHref
(
'/owners/package/'
.
$id
.
'/'
);
$list
->
addItem
(
$item
);
}
$result
=
new
PhabricatorApplicationSearchResultView
();
$result
->
setObjectList
(
$list
);
$result
->
setNoDataString
(
pht
(
'No packages found.'
));
return
$result
;
}
}
Event Timeline
Log In to Comment