You are here

protected function RestWSBaseFormat::getPropertyValues in RESTful Web Services 7.2

Transforms simple-array data values to valid entity property values.

This is the counter-part of $this->getData(), thus it converts resource references to the required value(s).

Parameters

array $values: The array representation of the data values.

$property_info: The property info array of the entity type for which we are transforming the values.

1 call to RestWSBaseFormat::getPropertyValues()
RestWSFormatJSON::unserialize in ./restws.formats.inc

File

./restws.formats.inc, line 260
RESTful web services module formats.

Class

RestWSBaseFormat
A base for all simple formats that are just serializing/unserializing an array of property values.

Code

protected function getPropertyValues(array &$values, $property_info) {
  foreach ($values as $name => &$property_value) {
    if (isset($property_info[$name]) && ($info = $property_info[$name])) {

      // Check if there is a resource array and if the property has a type.
      if (is_array($property_value) && isset($info['type'])) {

        // Check if the field is a list or a single value field.
        if (entity_property_list_extract_type($info['type'])) {

          // Check if the list values consist of structure wrappers.
          if (array_key_exists('property info', $info)) {
            foreach ($property_value as &$list_values) {
              $this
                ->getPropertyValues($list_values, $info['property info']);
            }
          }
          else {
            $list_type = entity_property_list_extract_type($info['type']);
            foreach ($property_value as &$list_value) {
              $list_value = $this
                ->getResourceReferenceValue($list_type, $list_value);
            }
          }
        }
        else {

          // Check if the property is a structure wrapper.
          if (array_key_exists('property info', $info)) {
            $this
              ->getPropertyValues($property_value, $info['property info']);
          }
          else {
            $property_value = $this
              ->getResourceReferenceValue($info['type'], $property_value);
          }
        }
      }
    }
  }
}