You are here

protected function Dom::getNonRootHtml in Migrate Plus 8.5

Same name and namespace in other branches
  1. 8.4 src/Plugin/migrate/process/Dom.php \Drupal\migrate_plus\Plugin\migrate\process\Dom::getNonRootHtml()

Builds an full html string based on a partial.

Parameters

string $partial: A subset of a full html string. For instance the contents of the body element.

1 call to Dom::getNonRootHtml()
Dom::import in src/Plugin/migrate/process/Dom.php
Converts a HTML string into a DOMDocument.

File

src/Plugin/migrate/process/Dom.php, line 215

Class

Dom
Handles string to DOM and back conversions.

Namespace

Drupal\migrate_plus\Plugin\migrate\process

Code

protected function getNonRootHtml($partial) {
  $replacements = [
    "\n" => '',
    '!encoding' => strtolower($this->configuration['encoding']),
    '!value' => $partial,
  ];

  // Prepend the html with a header using the configured source encoding.
  // By default, loadHTML() assumes ISO-8859-1.
  $html_template = <<<EOD
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="Content-Type" content="text/html; charset=!encoding" /></head>
<body>!value</body>
</html>
EOD;
  return strtr($html_template, $replacements);
}