function jsonapi_entity_base_field_info in JSON:API 8
Implements hook_entity_base_field_info().
@todo This should probably live in core, but for now we will keep it as a temporary solution. There are similar unresolved efforts already happening there.
See also
https://www.drupal.org/node/2825487
File
- ./
jsonapi.module, line 109 - Module implementation file.
Code
function jsonapi_entity_base_field_info(EntityTypeInterface $entity_type) {
$fields = [];
if ($entity_type
->id() == 'file') {
$fields['url'] = BaseFieldDefinition::create('string')
->setLabel(t('Download URL'))
->setDescription(t('The download URL of the file.'))
->setComputed(TRUE)
->setCustomStorage(TRUE)
->setClass('\\Drupal\\jsonapi\\Field\\FileDownloadUrl')
->setDisplayOptions('view', [
'label' => 'above',
'weight' => -5,
'region' => 'hidden',
])
->setDisplayConfigurable('view', TRUE);
}
return $fields;
}