You are here

protected function RestfulEntityBase::getValueFromProperty in RESTful 7

Get value from a property.

Parameters

EntityMetadataWrapper $wrapper: The wrapped entity.

EntityMetadataWrapper $sub_wrapper: The wrapped property.

array $info: The public field info array.

$public_field_name: The field name.

Return value

mixed A single or multiple values.

1 call to RestfulEntityBase::getValueFromProperty()
RestfulEntityBase::viewEntity in plugins/restful/RestfulEntityBase.php
View an entity.

File

plugins/restful/RestfulEntityBase.php, line 389
Contains RestfulEntityBase.

Class

RestfulEntityBase
An abstract implementation of RestfulEntityInterface.

Code

protected function getValueFromProperty(\EntityMetadataWrapper $wrapper, \EntityMetadataWrapper $sub_wrapper, array $info, $public_field_name) {
  $property = $info['property'];
  $method = $info['wrapper_method'];
  $resource = $info['resource'] ?: NULL;
  if ($info['sub_property'] && $sub_wrapper
    ->value()) {
    $sub_wrapper = $sub_wrapper->{$info['sub_property']};
  }
  if ($resource) {
    $value = $this
      ->getValueFromResource($sub_wrapper, $property, $resource, $public_field_name, $wrapper
      ->getIdentifier());
  }
  else {

    // Wrapper method.
    $value = $sub_wrapper
      ->{$method}();
  }
  return $value;
}