Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F547941
PhabricatorStandardCustomFieldSelect.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
4 KB
Referenced Files
None
Subscribers
None
PhabricatorStandardCustomFieldSelect.php
View Options
<?php
final
class
PhabricatorStandardCustomFieldSelect
extends
PhabricatorStandardCustomField
{
public
function
getFieldType
()
{
return
'select'
;
}
public
function
buildFieldIndexes
()
{
$indexes
=
array
();
$value
=
$this
->
getFieldValue
();
if
((
$value
!==
null
)
&&
(
strlen
(
$value
)))
{
$indexes
[]
=
$this
->
newStringIndex
(
$value
);
}
return
$indexes
;
}
public
function
readApplicationSearchValueFromRequest
(
PhabricatorApplicationSearchEngine
$engine
,
AphrontRequest
$request
)
{
return
$request
->
getArr
(
$this
->
getFieldKey
());
}
public
function
applyApplicationSearchConstraintToQuery
(
PhabricatorApplicationSearchEngine
$engine
,
PhabricatorCursorPagedPolicyAwareQuery
$query
,
$value
)
{
if
(
$value
)
{
$query
->
withApplicationSearchContainsConstraint
(
$this
->
newStringIndex
(
null
),
$value
);
}
}
public
function
appendToApplicationSearchForm
(
PhabricatorApplicationSearchEngine
$engine
,
AphrontFormView
$form
,
$value
)
{
if
(!
is_array
(
$value
))
{
$value
=
array
();
}
$value
=
array_fuse
(
$value
);
$control
=
id
(
new
AphrontFormCheckboxControl
())
->
setLabel
(
$this
->
getFieldName
());
foreach
(
$this
->
getOptions
()
as
$name
=>
$option
)
{
$control
->
addCheckbox
(
$this
->
getFieldKey
().
'[]'
,
$name
,
$option
,
isset
(
$value
[
$name
]));
}
$form
->
appendChild
(
$control
);
}
public
function
getOptions
()
{
return
$this
->
getFieldConfigValue
(
'options'
,
array
());
}
public
function
renderEditControl
(
array
$handles
)
{
return
id
(
new
AphrontFormSelectControl
())
->
setLabel
(
$this
->
getFieldName
())
->
setCaption
(
$this
->
getCaption
())
->
setName
(
$this
->
getFieldKey
())
->
setValue
(
$this
->
getFieldValue
())
->
setOptions
(
$this
->
getOptions
());
}
protected
function
renderValue
()
{
if
(!
phutil_nonempty_string
(
$this
->
getFieldValue
()))
{
return
null
;
}
return
idx
(
$this
->
getOptions
(),
$this
->
getFieldValue
());
}
public
function
getApplicationTransactionTitle
(
PhabricatorApplicationTransaction
$xaction
)
{
$author_phid
=
$xaction
->
getAuthorPHID
();
$old
=
$xaction
->
getOldValue
();
$new
=
$xaction
->
getNewValue
();
$old
=
idx
(
$this
->
getOptions
(),
$old
,
$old
);
$new
=
idx
(
$this
->
getOptions
(),
$new
,
$new
);
if
(!
$old
)
{
return
pht
(
'%s set %s to %s.'
,
$xaction
->
renderHandleLink
(
$author_phid
),
$this
->
getFieldName
(),
$new
);
}
else
if
(!
$new
)
{
return
pht
(
'%s removed %s.'
,
$xaction
->
renderHandleLink
(
$author_phid
),
$this
->
getFieldName
());
}
else
{
return
pht
(
'%s changed %s from %s to %s.'
,
$xaction
->
renderHandleLink
(
$author_phid
),
$this
->
getFieldName
(),
$old
,
$new
);
}
}
public
function
shouldAppearInHerald
()
{
return
true
;
}
public
function
getHeraldFieldConditions
()
{
return
array
(
HeraldAdapter
::
CONDITION_IS_ANY
,
HeraldAdapter
::
CONDITION_IS_NOT_ANY
,
);
}
public
function
getHeraldFieldValueType
(
$condition
)
{
$parameters
=
array
(
'object'
=>
get_class
(
$this
->
getObject
()),
'role'
=>
PhabricatorCustomField
::
ROLE_HERALD
,
'key'
=>
$this
->
getFieldKey
(),
);
$datasource
=
id
(
new
PhabricatorStandardSelectCustomFieldDatasource
())
->
setParameters
(
$parameters
);
return
id
(
new
HeraldTokenizerFieldValue
())
->
setKey
(
'custom.'
.
$this
->
getFieldKey
())
->
setDatasource
(
$datasource
)
->
setValueMap
(
$this
->
getOptions
());
}
protected
function
getHTTPParameterType
()
{
return
new
AphrontSelectHTTPParameterType
();
}
protected
function
newConduitSearchParameterType
()
{
return
new
ConduitStringListParameterType
();
}
protected
function
newConduitEditParameterType
()
{
return
new
ConduitStringParameterType
();
}
protected
function
newBulkParameterType
()
{
return
id
(
new
BulkSelectParameterType
())
->
setOptions
(
$this
->
getOptions
());
}
protected
function
newExportFieldType
()
{
return
id
(
new
PhabricatorOptionExportField
())
->
setOptions
(
$this
->
getOptions
());
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Mon, May 12, 1:40 PM (2 d)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
122921
Default Alt Text
PhabricatorStandardCustomFieldSelect.php (4 KB)
Attached To
Mode
rP Phorge
Attached
Detach File
Event Timeline
Log In to Comment