Updated to Drupal 8.5. Core Media not yet in use.
[yaffs-website] / vendor / chi-teck / drupal-code-generator / templates / d8 / hook / entity_field_storage_info.twig
1 /**
2  * Implements hook_entity_field_storage_info().
3  */
4 function {{ machine_name }}_entity_field_storage_info(\Drupal\Core\Entity\EntityTypeInterface $entity_type) {
5   if (\Drupal::entityManager()->getStorage($entity_type->id()) instanceof DynamicallyFieldableEntityStorageInterface) {
6     // Query by filtering on the ID as this is more efficient than filtering
7     // on the entity_type property directly.
8     $ids = \Drupal::entityQuery('field_storage_config')
9       ->condition('id', $entity_type->id() . '.', 'STARTS_WITH')
10       ->execute();
11     // Fetch all fields and key them by field name.
12     $field_storages = FieldStorageConfig::loadMultiple($ids);
13     $result = [];
14     foreach ($field_storages as $field_storage) {
15       $result[$field_storage->getName()] = $field_storage;
16     }
17
18     return $result;
19   }
20 }