1 filter.module | _filter_get_file_ids_by_field(EntityInterface $entity) |
Finds all files referenced (data-file-id) by processed text fields.
Parameters
EntityInterface $entity: An entity whose fields to analyze.
Return value
array: An array of file entity FIDs.
File
- core/
modules/ filter/ filter.module, line 1844 - Framework for handling the filtering of content.
Code
function _filter_get_file_ids_by_field(EntityInterface $entity) {
$fids = array();
$processed_text_fields = _filter_get_processed_text_fields($entity);
foreach ($processed_text_fields as $processed_text_field) {
$fids[$processed_text_field] = array();
if (isset($entity->$processed_text_field)) {
foreach ($entity->$processed_text_field as $langcode => $values) {
foreach ($values as $delta => $text) {
if (isset($text['value'])) {
$fids[$processed_text_field] = array_merge($fids[$processed_text_field], filter_parse_file_fids($text['value']));
}
if (isset($text['summary'])) {
$fids[$processed_text_field] = array_merge($fids[$processed_text_field], filter_parse_file_fids($text['summary']));
}
}
}
}
$fids[$processed_text_field] = array_unique($fids[$processed_text_field]);
}
return $fids;
}