W3cubDocs

/Drupal 8

function _editor_get_file_uuids_by_field

_editor_get_file_uuids_by_field(EntityInterface $entity)

Finds all files referenced (data-entity-uuid) by formatted text fields.

Parameters

EntityInterface $entity: An entity whose fields to analyze.

Return value

array An array of file entity UUIDs.

File

core/modules/editor/editor.module, line 465
Adds bindings for client-side "text editors" to text formats.

Code

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