protected function PageProcessor::loadDocument in Mini site 8
Load document from the string.
Parameters
string $content: The content to load. Should be an HTML page that can be parsed.
Return value
\DOMDocument DOM Document object with loaded content.
Throws
\Drupal\minisite\Exception\PageProcessorException If provided content is not valid HTML or empty.
1 call to PageProcessor::loadDocument()
- PageProcessor::__construct in src/
PageProcessor.php - PageProcessor constructor.
File
- src/
PageProcessor.php, line 266
Class
- PageProcessor
- Class PageProcessor.
Namespace
Drupal\minisiteCode
protected function loadDocument($content) {
libxml_use_internal_errors(TRUE);
$document = new \DOMDocument();
$content = $this
->cleanupContent($content);
$loaded = $document
->loadHTML($content);
if (!$loaded || empty($document) || empty($document->textContent)) {
throw new PageProcessorException(sprintf('Unable to parse document: %s', libxml_get_last_error()));
}
return $document;
}