Problem/Motivation
\Drupal\field\Entity\FieldStorageConfig::id():
public function id() {
return $this->getTargetEntityTypeId() . '.' . $this->getName();
}
and \Drupal\field\Entity\FieldStorageConfig::loadByName():
public static function loadByName($entity_type_id, $field_name) {
return \Drupal::entityTypeManager()->getStorage('field_storage_config')->load($entity_type_id . '.' . $field_name);
}
and worse:
\Drupal\Core\Field\FieldConfigBase::id():
public function id() {
return $this->entity_type . '.' . $this->bundle . '.' . $this->field_name;
}
and \Drupal\field\Entity\FieldConfig::loadByName():
public static function loadByName($entity_type_id, $bundle, $field_name) {
return \Drupal::entityTypeManager()->getStorage('field_config')->load($entity_type_id . '.' . $bundle . '.' . $field_name);
}
(Same thing for \Drupal\Core\Field\Entity\BaseFieldOverride::loadByName(): 3 parameters that together create the name/ID.)
The corresponding config entity type annotations do not have any metadata at all that would allow us to construct these IDs automatically. They contain a config_prefix key-value pair, but not something like a config_name_parts key-value pair.
Until Drupal core provides an API for this, we have no choice but to hardcode these three. We can find them by searching for .*.* in *.schema.yml files.
But … that's how we can discover there's actually several more: core.entity_view_mode.*.*, core.entity_form_mode.*.*, core.entity_view_display.*.*.* and core.entity_form_display.*.*.*. For these, all of the mapping/loading logic is embedded in \Drupal\Core\Entity\EntityDisplayRepository.
Steps to reproduce
Proposed resolution
Harden \Drupal\jsonapi_schema\StaticDataDefinitionExtractor::extractConfigEntityType().
Remaining tasks
User interface changes
API changes
Data model changes
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | jsonapi_schema_multipart_id_config_entity_types-3324769-2.patch | 1.94 KB | wim leers |
Comments
Comment #2
wim leersResponse for
/jsonapi/field_storage_config/field_storage_config/resource/schema:(Note how
typenow appears for everything, unlike before!)Comment #3
wim leersNote this is a blocker for https://www.drupal.org/project/field_ui_modern.
Comment #4
m.stentaI discovered this too while writing automated tests in #3257911: Add basic test coverage. I had to hard-code those same six entity types as exceptions in the tests to make them pass. If we merge this, we can remove that exception from the tests.