1 filter.module _filter_record_file_usage(array $fids, EntityInterface $entity)

Records file usage of files referenced by processed text fields.

Every referenced file that does not yet have the FILE_STATUS_PERMANENT state, will be given that state.

Parameters

array $fids: An array of file entity IDs.

EntityInterface $entity: An entity whose fields to inspect for file references.

File

core/modules/filter/filter.module, line 1751
Framework for handling the filtering of content.

Code

function _filter_record_file_usage(array $fids, EntityInterface $entity) {
  foreach ($fids as $fid) {
    $file = file_load($fid);
    if ($file) {
      if ($file->status != FILE_STATUS_PERMANENT) {
        $file->status = FILE_STATUS_PERMANENT;
        $file->save();
      }
      file_usage_add($file, 'filter', $entity->entityType(), $entity->id());
    }
  }
}