_editor_delete_file_usage(array $uuids, EntityInterface $entity, $count)
Deletes file usage of files referenced by formatted text fields.
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.
\Drupal\file\FileUsage\FileUsageInterface::delete()
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