W3cubDocs

/Drupal 8

function _editor_delete_file_usage

_editor_delete_file_usage(array $uuids, EntityInterface $entity, $count)

Deletes file usage of files referenced by formatted text fields.

Parameters

array $uuids: An array of file entity UUIDs.

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()

File

core/modules/editor/editor.module, line 448
Adds bindings for client-side "text editors" to text formats.

Code

function _editor_delete_file_usage(array $uuids, EntityInterface $entity, $count) {
  foreach ($uuids as $uuid) {
    if ($file = \Drupal::entityManager()->loadEntityByUuid('file', $uuid)) {
      \Drupal::service('file.usage')->delete($file, 'editor', $entity->getEntityTypeId(), $entity->id(), $count);
    }
  }
}

© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!modules!editor!editor.module/function/_editor_delete_file_usage/8.1.x