function _editor_record_file_usage
Same name in other branches
- 9 core/modules/editor/editor.module \_editor_record_file_usage()
- 8.9.x core/modules/editor/editor.module \_editor_record_file_usage()
- 10 core/modules/editor/editor.module \_editor_record_file_usage()
Records file usage of files referenced by formatted text fields.
Every referenced file that is temporally saved will be resaved as permanent.
Parameters
array $uuids: An array of file entity UUIDs.
\Drupal\Core\Entity\EntityInterface $entity: An entity whose fields to inspect for file references.
2 calls to _editor_record_file_usage()
- editor_entity_insert in core/
modules/ editor/ editor.module - Implements hook_entity_insert().
- editor_entity_update in core/
modules/ editor/ editor.module - Implements hook_entity_update().
File
-
core/
modules/ editor/ editor.module, line 455
Code
function _editor_record_file_usage(array $uuids, EntityInterface $entity) {
foreach ($uuids as $uuid) {
if ($file = \Drupal::service('entity.repository')->loadEntityByUuid('file', $uuid)) {
/** @var \Drupal\file\FileInterface $file */
if ($file->isTemporary()) {
$file->setPermanent();
$file->save();
}
\Drupal::service('file.usage')->add($file, 'editor', $entity->getEntityTypeId(), $entity->id());
}
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.