You are here

protected function PopupMessageSettingsForm::extractFilesUuid in Popup message 8

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.

1 call to PopupMessageSettingsForm::extractFilesUuid()
PopupMessageSettingsForm::submitForm in src/Form/PopupMessageSettingsForm.php
Form submission handler.

File

src/Form/PopupMessageSettingsForm.php, line 311

Class

PopupMessageSettingsForm
Class PopupMessageSettingsForm.

Namespace

Drupal\popup_message\Form

Code

protected function extractFilesUuid($text) {
  $dom = Html::load($text);
  $xpath = new \DOMXPath($dom);
  $uuids = [];
  foreach ($xpath
    ->query('//*[@data-entity-type="file" and @data-entity-uuid]') as $file) {
    $uuids[] = $file
      ->getAttribute('data-entity-uuid');
  }
  return $uuids;
}