public function EntityParser::getPublicFieldName in Entity Share 8.3
Helper: returns JSON:API public field name of one entity's remote data.
Parameters
string $field_name: The local Drupal field name.
array $entity_json_data: The JSON:API data for a single entity.
Return value
string The public field name or an empty string if not applicable.
2 calls to EntityParser::getPublicFieldName()
- EntityParser::getRemoteChangedTime in modules/
entity_share_diff/ src/ Service/ EntityParser.php - Gets 'changed' timestamp of remote entity, if available.
- EntityParser::parseEntity in modules/
entity_share_diff/ src/ Service/ EntityParser.php - Parses an entity.
File
- modules/
entity_share_diff/ src/ Service/ EntityParser.php, line 179
Class
- EntityParser
- Entity parser.
Namespace
Drupal\entity_share_diff\ServiceCode
public function getPublicFieldName(string $field_name, array $entity_json_data) {
if (empty($entity_json_data['type'])) {
return '';
}
$parsed_type = explode('--', $entity_json_data['type']);
$entity_type_id = $parsed_type[0];
$bundle = $parsed_type[1];
$resource_type = $this->resourceTypeRepository
->get($entity_type_id, $bundle);
if (!$resource_type instanceof ResourceType) {
return '';
}
if (!$resource_type
->hasField($field_name)) {
return '';
}
return $resource_type
->getPublicName($field_name);
}