Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F99304478
PhabricatorSearchTokenizerField.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
Thu, Jan 23, 07:05
Size
1 KB
Mime Type
text/x-php
Expires
Sat, Jan 25, 07:05 (2 d)
Engine
blob
Format
Raw Data
Handle
23727695
Attached To
rPH Phabricator
PhabricatorSearchTokenizerField.php
View Options
<?php
abstract
class
PhabricatorSearchTokenizerField
extends
PhabricatorSearchField
{
protected
function
getDefaultValue
()
{
return
array
();
}
protected
function
getValueFromRequest
(
AphrontRequest
$request
,
$key
)
{
return
$this
->
getListFromRequest
(
$request
,
$key
);
}
public
function
getValueForQuery
(
$value
)
{
return
$this
->
newDatasource
()
->
setViewer
(
$this
->
getViewer
())
->
evaluateTokens
(
$value
);
}
protected
function
newControl
()
{
return
id
(
new
AphrontFormTokenizerControl
())
->
setDatasource
(
$this
->
newDatasource
());
}
abstract
protected
function
newDatasource
();
protected
function
getUsersFromRequest
(
AphrontRequest
$request
,
$key
,
array
$allow_types
=
array
())
{
$list
=
$this
->
getListFromRequest
(
$request
,
$key
);
$phids
=
array
();
$names
=
array
();
$allow_types
=
array_fuse
(
$allow_types
);
$user_type
=
PhabricatorPeopleUserPHIDType
::
TYPECONST
;
foreach
(
$list
as
$item
)
{
$type
=
phid_get_type
(
$item
);
if
(
$type
==
$user_type
)
{
$phids
[]
=
$item
;
}
else
if
(
isset
(
$allow_types
[
$type
]))
{
$phids
[]
=
$item
;
}
else
{
if
(
PhabricatorTypeaheadDatasource
::
isFunctionToken
(
$item
))
{
// If this is a function, pass it through unchanged; we'll evaluate
// it later.
$phids
[]
=
$item
;
}
else
{
$names
[]
=
$item
;
}
}
}
if
(
$names
)
{
$users
=
id
(
new
PhabricatorPeopleQuery
())
->
setViewer
(
$this
->
getViewer
())
->
withUsernames
(
$names
)
->
execute
();
foreach
(
$users
as
$user
)
{
$phids
[]
=
$user
->
getPHID
();
}
$phids
=
array_unique
(
$phids
);
}
return
$phids
;
}
}
Event Timeline
Log In to Comment