You are here

protected function RestfulEntityBase::propertyValuesPreprocessFile in RESTful 7

Preprocess value for "File" 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::propertyValuesPreprocessFile()
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 969
Contains RestfulEntityBase.

Class

RestfulEntityBase
An abstract implementation of RestfulEntityInterface.

Code

protected function propertyValuesPreprocessFile($property_name, $value, $field_info) {
  if ($field_info['cardinality'] == 1) {

    // Single value.
    return array(
      'fid' => $value,
      'display' => TRUE,
    );
  }
  $value = is_array($value) ? $value : explode(',', $value);
  $return = array();
  foreach ($value as $delta => $single_value) {
    $return[$delta] = array(
      'fid' => $single_value,
      'display' => TRUE,
    );
  }
  return $return;
}