Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F81571263
PhabricatorOwnersPackageDatasource.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, Sep 6, 19:48
Size
1 KB
Mime Type
text/x-php
Expires
Sun, Sep 8, 19:48 (2 d)
Engine
blob
Format
Raw Data
Handle
20597700
Attached To
rPH Phabricator
PhabricatorOwnersPackageDatasource.php
View Options
<?php
final
class
PhabricatorOwnersPackageDatasource
extends
PhabricatorTypeaheadDatasource
{
public
function
getBrowseTitle
()
{
return
pht
(
'Browse Packages'
);
}
public
function
getPlaceholderText
()
{
return
pht
(
'Type a package name...'
);
}
public
function
getDatasourceApplicationClass
()
{
return
'PhabricatorOwnersApplication'
;
}
public
function
loadResults
()
{
$viewer
=
$this
->
getViewer
();
$raw_query
=
$this
->
getRawQuery
();
$results
=
array
();
$query
=
id
(
new
PhabricatorOwnersPackageQuery
())
->
setOrder
(
'name'
);
// If the user is querying by monogram explicitly, like "O123", do an ID
// search. Otherwise, do an ngram substring search.
if
(
preg_match
(
'/^[oO]
\d
+
\z
/'
,
$raw_query
))
{
$id
=
trim
(
$raw_query
,
'oO'
);
$id
=
(
int
)
$id
;
$query
->
withIDs
(
array
(
$id
));
}
else
{
$query
->
withNameNgrams
(
$raw_query
);
}
$packages
=
$this
->
executeQuery
(
$query
);
foreach
(
$packages
as
$package
)
{
$name
=
$package
->
getName
();
$monogram
=
$package
->
getMonogram
();
$results
[]
=
id
(
new
PhabricatorTypeaheadResult
())
->
setName
(
"{$monogram}: {$name}"
)
->
setURI
(
$package
->
getURI
())
->
setPHID
(
$package
->
getPHID
());
}
return
$this
->
filterResultsAgainstTokens
(
$results
);
}
}
Event Timeline
Log In to Comment