function _editor_delete_file_usage

Same name and namespace in other branches
  1. 10 core/modules/editor/editor.module \_editor_delete_file_usage()
  2. 9 core/modules/editor/editor.module \_editor_delete_file_usage()
  3. 8.9.x core/modules/editor/editor.module \_editor_delete_file_usage()

Deletes file usage of files referenced by formatted text fields.

Parameters

array $uuids: An array of file entity UUIDs.

\Drupal\Core\Entity\EntityInterface $entity: An entity whose fields to inspect for file references.

int $count: The number of references to delete. Should be 1 when deleting a single revision and 0 when deleting an entity entirely.

Deprecated

in drupal:11.4.0 and is removed from drupal:12.0.0. No replacement is provided.

See also

https://www.drupal.org/node/3568136

\Drupal\file\FileUsage\FileUsageInterface::delete()

File

core/modules/editor/editor.module, line 174

Code

function _editor_delete_file_usage(array $uuids, EntityInterface $entity, $count) : void {
  @trigger_error(__FUNCTION__ . '() is deprecated in drupal:11.4.0 and is removed from drupal:12.0.0. No replacement is provided. See https://www.drupal.org/node/3568136', E_USER_DEPRECATED);
  foreach ($uuids as $uuid) {
    if ($file = \Drupal::service('entity.repository')->loadEntityByUuid('file', $uuid)) {
      \Drupal::service('file.usage')->delete($file, 'editor', $entity->getEntityTypeId(), $entity->id(), $count);
    }
  }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.