function ctools_entity_mask_entity_field_storage_info

Same name in other branches
  1. 8.x-3.x modules/ctools_entity_mask/ctools_entity_mask.module \ctools_entity_mask_entity_field_storage_info()

Implements hook_entity_field_storage_info().

1 call to ctools_entity_mask_entity_field_storage_info()
ctools_entity_mask_entity_bundle_field_info in modules/ctools_entity_mask/ctools_entity_mask.module
Implements hook_entity_bundle_field_info().

File

modules/ctools_entity_mask/ctools_entity_mask.module, line 173

Code

function ctools_entity_mask_entity_field_storage_info(EntityTypeInterface $entity_type) {
    $info = [];
    $mask = $entity_type->get('mask');
    // Nothing to do if the entity type is not masking another entity type.
    if (empty($mask)) {
        return $info;
    }
    
    /** @var \Drupal\field\FieldStorageConfigInterface[] $fields */
    $fields = \Drupal::entityTypeManager()->getStorage('field_storage_config')
        ->loadByProperties([
        'entity_type' => $mask,
    ]);
    foreach ($fields as $field) {
        $field_name = $field->getName();
        $info[$field_name] = $field->createDuplicate()
            ->set('entity_type', $mask);
    }
    return $info;
}