W3cubDocs

/Drupal 8

function _editor_parse_file_uuids

_editor_parse_file_uuids($text)

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.

File

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

Code

function _editor_parse_file_uuids($text) {
  $dom = Html::load($text);
  $xpath = new \DOMXPath($dom);
  $uuids = array();
  foreach ($xpath->query('//*[@data-entity-type="file" and @data-entity-uuid]') as $node) {
    $uuids[] = $node->getAttribute('data-entity-uuid');
  }
  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_parse_file_uuids/8.1.x