function _editor_delete_file_usage

Same name and namespace in other branches
  1. 9 core/modules/editor/editor.module \_editor_delete_file_usage()
  2. 8.9.x core/modules/editor/editor.module \_editor_delete_file_usage()
  3. 10 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.

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

See also

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

5 calls to _editor_delete_file_usage()
editor_entity_delete in core/modules/editor/editor.module
Implements hook_entity_delete().
editor_entity_revision_delete in core/modules/editor/editor.module
Implements hook_entity_revision_delete().
editor_entity_update in core/modules/editor/editor.module
Implements hook_entity_update().
hook_entity_revision_delete in core/lib/Drupal/Core/Entity/entity.api.php
Respond to entity revision deletion.
hook_ENTITY_TYPE_revision_delete in core/lib/Drupal/Core/Entity/entity.api.php
Respond to entity revision deletion of a particular type.

File

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

Code

function _editor_delete_file_usage(array $uuids, EntityInterface $entity, $count) {
    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.