function ResourceTypeRepository::getAllFieldNames
Same name in other branches
- 9 core/modules/jsonapi/src/ResourceType/ResourceTypeRepository.php \Drupal\jsonapi\ResourceType\ResourceTypeRepository::getAllFieldNames()
- 10 core/modules/jsonapi/src/ResourceType/ResourceTypeRepository.php \Drupal\jsonapi\ResourceType\ResourceTypeRepository::getAllFieldNames()
- 11.x core/modules/jsonapi/src/ResourceType/ResourceTypeRepository.php \Drupal\jsonapi\ResourceType\ResourceTypeRepository::getAllFieldNames()
Gets all field names for a given entity type and bundle.
Parameters
\Drupal\Core\Entity\EntityTypeInterface $entity_type: The entity type for which to get all field names.
string $bundle: The bundle for which to get all field names.
Return value
string[] All field names.
2 calls to ResourceTypeRepository::getAllFieldNames()
- CountableResourceTypeRepository::createResourceType in core/
modules/ jsonapi/ tests/ modules/ jsonapi_test_collection_count/ src/ ResourceType/ CountableResourceTypeRepository.php - Creates a ResourceType value object for the given entity type + bundle.
- ResourceTypeRepository::createResourceType in core/
modules/ jsonapi/ src/ ResourceType/ ResourceTypeRepository.php - Creates a ResourceType value object for the given entity type + bundle.
File
-
core/
modules/ jsonapi/ src/ ResourceType/ ResourceTypeRepository.php, line 340
Class
- ResourceTypeRepository
- Provides a repository of all JSON:API resource types.
Namespace
Drupal\jsonapi\ResourceTypeCode
protected function getAllFieldNames(EntityTypeInterface $entity_type, $bundle) {
if ($entity_type instanceof ContentEntityTypeInterface) {
$field_definitions = $this->entityFieldManager
->getFieldDefinitions($entity_type->id(), $bundle);
return array_keys($field_definitions);
}
elseif ($entity_type instanceof ConfigEntityTypeInterface) {
// @todo Uncomment the first line, remove everything else once https://www.drupal.org/project/drupal/issues/2483407 lands.
// return array_keys($entity_type->getPropertiesToExport());
$export_properties = $entity_type->getPropertiesToExport();
if ($export_properties !== NULL) {
return array_keys($export_properties);
}
else {
return [
'id',
'type',
'uuid',
'_core',
];
}
}
else {
throw new \LogicException("Only content and config entity types are supported.");
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.