function _editor_get_file_uuids_by_field

Same name and namespace in other branches
  1. 9 core/modules/editor/editor.module \_editor_get_file_uuids_by_field()
  2. 8.9.x core/modules/editor/editor.module \_editor_get_file_uuids_by_field()
  3. 10 core/modules/editor/editor.module \_editor_get_file_uuids_by_field()

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

Parameters

\Drupal\Core\Entity\EntityInterface $entity: An entity whose fields to analyze.

Return value

array An array of file entity UUIDs.

6 calls to _editor_get_file_uuids_by_field()
editor_entity_delete in core/modules/editor/editor.module
Implements hook_entity_delete().
editor_entity_insert in core/modules/editor/editor.module
Implements hook_entity_insert().
editor_entity_revision_delete in core/modules/editor/editor.module
Implements hook_entity_revision_delete().
editor_entity_update in core/modules/editor/editor.module
Implements hook_entity_update().
hook_entity_revision_delete in core/lib/Drupal/Core/Entity/entity.api.php
Respond to entity revision deletion.

... See full list

File

core/modules/editor/editor.module, line 559

Code

function _editor_get_file_uuids_by_field(EntityInterface $entity) {
    $uuids = [];
    $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;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.