_editor_get_file_uuids_by_field(EntityInterface $entity)
Finds all files referenced (data-entity-uuid) by formatted text fields.
EntityInterface $entity: An entity whose fields to analyze.
array An array of file entity UUIDs.
function _editor_get_file_uuids_by_field(EntityInterface $entity) { $uuids = array(); $formatted_text_fields = _editor_get_formatted_text_fields($entity); foreach ($formatted_text_fields as $formatted_text_field) { $text = ''; $field_items = $entity->get($formatted_text_field); foreach ($field_items as $field_item) { $text .= $field_item->value; if ($field_item->getFieldDefinition()->getType() == 'text_with_summary') { $text .= $field_item->summary; } } $uuids[$formatted_text_field] = _editor_parse_file_uuids($text); } return $uuids; }
© 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_get_file_uuids_by_field/8.1.x