protected function ResourceFieldEntity::buildResourceMetadataItem in RESTful 7.2
Builds a metadata item for a field value.
It will add information about the referenced entity. NOTE: Do not type hint the $wrapper argument to avoid PHP errors for the file entities. Those are no true entity references, but file arrays (although they reference file entities)
Parameters
\EntityDrupalWrapper $wrapper: The wrapper to the referenced entity.
Return value
array The metadata array item.
2 calls to ResourceFieldEntity::buildResourceMetadataItem()
- ResourceFieldEntity::singleValue in src/
Plugin/ resource/ Field/ ResourceFieldEntity.php - Returns the value for the current single field.
- ResourceFieldFileEntityReference::buildResourceMetadataItem in src/
Plugin/ resource/ Field/ ResourceFieldFileEntityReference.php - Builds a metadata item for a field value.
1 method overrides ResourceFieldEntity::buildResourceMetadataItem()
- ResourceFieldFileEntityReference::buildResourceMetadataItem in src/
Plugin/ resource/ Field/ ResourceFieldFileEntityReference.php - Builds a metadata item for a field value.
File
- src/
Plugin/ resource/ Field/ ResourceFieldEntity.php, line 1116 - Contains \Drupal\restful\Plugin\resource\Field\ResourceFieldEntity
Class
- ResourceFieldEntity
- Class ResourceFieldEntity.
Namespace
Drupal\restful\Plugin\resource\FieldCode
protected function buildResourceMetadataItem($wrapper) {
if ($wrapper instanceof \EntityValueWrapper) {
$wrapper = entity_metadata_wrapper($this
->getEntityType(), $wrapper
->value());
}
$id = $wrapper
->getIdentifier();
$bundle = $wrapper
->getBundle();
$resource = $this
->getResource();
return array(
'id' => $id,
'entity_type' => $wrapper
->type(),
'bundle' => $bundle,
'resource_name' => $resource['name'],
);
}