Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F108486174
HeraldTokenizerFieldValue.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, Apr 17, 01:32
Size
2 KB
Mime Type
text/x-php
Expires
Sat, Apr 19, 01:32 (2 d)
Engine
blob
Format
Raw Data
Handle
25588205
Attached To
rPH Phabricator
HeraldTokenizerFieldValue.php
View Options
<?php
final
class
HeraldTokenizerFieldValue
extends
HeraldFieldValue
{
private
$key
;
private
$datasource
;
private
$valueMap
;
public
function
setKey
(
$key
)
{
$this
->
key
=
$key
;
return
$this
;
}
public
function
getKey
()
{
return
$this
->
key
;
}
public
function
setDatasource
(
PhabricatorTypeaheadDatasource
$datasource
)
{
$this
->
datasource
=
$datasource
;
return
$this
;
}
public
function
getDatasource
()
{
return
$this
->
datasource
;
}
public
function
setValueMap
(
array
$value_map
)
{
$this
->
valueMap
=
$value_map
;
return
$this
;
}
public
function
getValueMap
()
{
return
$this
->
valueMap
;
}
public
function
getFieldValueKey
()
{
if
(
$this
->
getKey
()
===
null
)
{
throw
new
PhutilInvalidStateException
(
'setKey'
);
}
return
'tokenizer.'
.
$this
->
getKey
();
}
public
function
getControlType
()
{
return
self
::
CONTROL_TOKENIZER
;
}
protected
function
getControlTemplate
()
{
if
(
$this
->
getDatasource
()
===
null
)
{
throw
new
PhutilInvalidStateException
(
'setDatasource'
);
}
$datasource
=
$this
->
getDatasource
();
$datasource
->
setViewer
(
$this
->
getViewer
());
return
array
(
'tokenizer'
=>
array
(
'datasourceURI'
=>
$datasource
->
getDatasourceURI
(),
'browseURI'
=>
$datasource
->
getBrowseURI
(),
'placeholder'
=>
$datasource
->
getPlaceholderText
(),
),
);
}
public
function
renderFieldValue
(
$value
)
{
$viewer
=
$this
->
getViewer
();
$value
=
(
array
)
$value
;
if
(
$this
->
valueMap
!==
null
)
{
foreach
(
$value
as
$k
=>
$v
)
{
$value
[
$k
]
=
idx
(
$this
->
valueMap
,
$v
,
$v
);
}
return
implode
(
', '
,
$value
);
}
return
$viewer
->
renderHandleList
((
array
)
$value
)->
setAsInline
(
true
);
}
public
function
renderEditorValue
(
$value
)
{
$viewer
=
$this
->
getViewer
();
$value
=
(
array
)
$value
;
// TODO: This should eventually render properly through the datasource
// to get icons and colors.
if
(
$this
->
valueMap
!==
null
)
{
$map
=
array
();
foreach
(
$value
as
$v
)
{
$map
[
$v
]
=
idx
(
$this
->
valueMap
,
$v
,
$v
);
}
return
$map
;
}
$handles
=
$viewer
->
loadHandles
(
$value
);
$map
=
array
();
foreach
(
$value
as
$v
)
{
$map
[
$v
]
=
$handles
[
$v
]->
getName
();
}
return
$map
;
}
}
Event Timeline
Log In to Comment