field_entity_field_storage_info(EntityTypeInterface $entity_type)
Implements hook_entity_field_storage_info().
Related topics
- Field API
- Attaches custom data fields to Drupal entities.
File
- core/modules/field/field.module, line 173
- Attach custom data fields to Drupal entities.
Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | function field_entity_field_storage_info(EntityTypeInterface $entity_type ) { if (\Drupal::entityManager()->getStorage( $entity_type ->id()) instanceof DynamicallyFieldableEntityStorageInterface) { // Query by filtering on the ID as this is more efficient than filtering // on the entity_type property directly. $ids = \Drupal::entityQuery( 'field_storage_config' ) ->condition( 'id' , $entity_type ->id() . '.' , 'STARTS_WITH' ) ->execute(); // Fetch all fields and key them by field name. $field_storages = FieldStorageConfig::loadMultiple( $ids ); $result = array (); foreach ( $field_storages as $field_storage ) { $result [ $field_storage ->getName()] = $field_storage ; } return $result ; } } |
Please login to continue.