function _editor_parse_file_uuids

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

Parse an HTML snippet for any linked file with data-entity-uuid attributes.

Parameters

string $text: The partial (X)HTML snippet to load. Invalid markup will be corrected on import.

Return value

array An array of all found UUIDs.

Deprecated

in drupal:11.4.0 and is removed from drupal:12.0.0. No replacement is provided.

See also

https://www.drupal.org/node/3568136

1 call to _editor_parse_file_uuids()
_editor_get_file_uuids_by_field in core/modules/editor/editor.module
Finds all files referenced (data-entity-uuid) by formatted text fields.

File

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

Code

function _editor_parse_file_uuids($text) : array {
  @trigger_error(__FUNCTION__ . '() is deprecated in drupal:11.4.0 and is removed from drupal:12.0.0. No replacement is provided. See https://www.drupal.org/node/3568136', E_USER_DEPRECATED);
  $dom = Html::load($text);
  $xpath = new \DOMXPath($dom);
  $uuids = [];
  foreach ($xpath->query('//*[@data-entity-type="file" and @data-entity-uuid]') as $node) {
    $uuids[] = $node->getAttribute('data-entity-uuid');
  }
  return $uuids;
}

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