protected function RestfulEntityBase::propertyValuesPreprocessText in RESTful 7
Preprocess value for "Text" related field types.
Parameters
string $property_name: The property name to set.
$value: The value passed in the request.
array $field_info: The field info array.
Return value
mixed The value to set using the wrapped property.
1 call to RestfulEntityBase::propertyValuesPreprocessText()
- RestfulEntityBase::propertyValuesPreprocess in plugins/
restful/ RestfulEntityBase.php - Massage the value to set according to the format expected by the wrapper.
File
- plugins/
restful/ RestfulEntityBase.php, line 925 - Contains RestfulEntityBase.
Class
- RestfulEntityBase
- An abstract implementation of RestfulEntityInterface.
Code
protected function propertyValuesPreprocessText($property_name, $value, $field_info) {
// Text field. Check if field has an input format.
$instance = field_info_instance($this
->getEntityType(), $property_name, $this
->getBundle());
if ($field_info['cardinality'] == 1) {
// Single value.
if (!$instance['settings']['text_processing']) {
return $value;
}
return array(
'value' => $value,
'format' => 'filtered_html',
);
}
// Multiple values.
foreach ($value as $delta => $single_value) {
if (!$instance['settings']['text_processing']) {
$return[$delta] = $single_value;
}
else {
$return[$delta] = array(
'value' => $single_value,
'format' => 'filtered_html',
);
}
}
return $return;
}