You are here

protected function ResourceFieldFileEntityReference::referencedId in RESTful 7.2

Helper function to get the referenced entity ID.

Parameters

\EntityStructureWrapper $property_wrapper: The wrapper for the referenced file array.

Return value

mixed The ID.

Overrides ResourceFieldEntityReference::referencedId

File

src/Plugin/resource/Field/ResourceFieldFileEntityReference.php, line 86
Contains \Drupal\restful\Plugin\resource\Field\ResourceFieldFileEntityReference.

Class

ResourceFieldFileEntityReference

Namespace

Drupal\restful\Plugin\resource\Field

Code

protected function referencedId($property_wrapper) {
  $file_array = $property_wrapper
    ->value();
  if (!$this->referencedIdProperty) {
    return $file_array['fid'];
  }

  /* @var \EntityDrupalWrapper $wrapper */
  $wrapper = entity_metadata_wrapper('file', $file_array['fid']);
  return $wrapper->{$this->referencedIdProperty}
    ->value();
}