protected function EntityLoadHelper::identifyAttributeType in YAML Content 8
Identify data keys as properties, fields, or other.
@todo Use entity type information to more accurately identify attributes.
Parameters
string $entity_type: The entity type ID.
string $key: The data key being identified.
Return value
string The type of attribute being identified. This value may be one of:
- property All values defined as entity keys will be indicated as properties.
- field Defined fields for the entity type not indicated as entity keys will be indicated as fields.
- other All other values will be categorized here.
1 call to EntityLoadHelper::identifyAttributeType()
- EntityLoadHelper::categorizeAttributes in src/
Service/ EntityLoadHelper.php - Group content data attributes by type.
File
- src/
Service/ EntityLoadHelper.php, line 278
Class
- EntityLoadHelper
- A helper class to support identification and loading of existing entities.
Namespace
Drupal\yaml_content\ServiceCode
protected function identifyAttributeType($entity_type, $key) {
// Load the list of fields defined for the entity type.
// @todo Add validation that the entity type is listed here.
$field_list = $this
->getEntityFields($entity_type);
$entity_definition = $this
->getEntityDefinition($entity_type);
if ($entity_definition
->hasKey($key)) {
$attribute_type = 'property';
}
elseif ($entity_definition instanceof ConfigEntityTypeInterface && in_array($key, $entity_definition
->getPropertiesToExport())) {
$attribute_type = 'property';
}
elseif (is_array($field_list) && array_key_exists($key, $field_list)) {
$attribute_type = 'field';
}
else {
$attribute_type = 'other';
}
return $attribute_type;
}