Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. ImageHooks.php

function ImageHooks::fieldStorageConfigDelete

Implements hook_ENTITY_TYPE_delete() for 'field_storage_config'.

File

core/modules/image/src/Hook/ImageHooks.php, line 348

Class

ImageHooks
Hook implementations for image.

Namespace

Drupal\image\Hook

Code

public function fieldStorageConfigDelete(FieldStorageConfigInterface $field) {
    if ($field->getType() != 'image') {
        // Only act on image fields.
        return;
    }
    // The value of a managed_file element can be an array if #extended == TRUE.
    $uuid = $field->getSetting('default_image')['uuid'];
    if ($uuid && ($file = \Drupal::service('entity.repository')->loadEntityByUuid('file', $uuid))) {
        \Drupal::service('file.usage')->delete($file, 'image', 'default_image', $field->uuid());
    }
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal