You are here

protected function ParserBase::prepareRaw in Feeds extensible parsers 8

Prepares the raw string for parsing.

Parameters

\Drupal\feeds\Result\FetcherResultInterface $fetcher_result: The fetcher result.

Return value

string The prepared raw string.

5 calls to ParserBase::prepareRaw()
HtmlParser::prepareDocument in src/Feeds/Parser/HtmlParser.php
Prepares the DOM document.
JmesPathParser::executeContext in src/Feeds/Parser/JmesPathParser.php
Returns rows to be parsed.
JsonPathParser::executeContext in src/Feeds/Parser/JsonPathParser.php
Returns rows to be parsed.
QueryPathHtmlParser::prepareDocument in src/Feeds/Parser/QueryPathHtmlParser.php
Prepares the DOM document.
XmlParser::prepareDocument in src/Feeds/Parser/XmlParser.php
Prepares the DOM document.

File

src/Feeds/Parser/ParserBase.php, line 408

Class

ParserBase
The Feeds extensible parser.

Namespace

Drupal\feeds_ex\Feeds\Parser

Code

protected function prepareRaw(FetcherResultInterface $fetcher_result) {
  $raw = $this
    ->getEncoder()
    ->convertEncoding($fetcher_result
    ->getRaw());

  // Strip null bytes.
  $raw = trim(str_replace("\0", '', $raw));

  // Check that the string has at least one character.
  if (!isset($raw[0])) {
    throw new EmptyFeedException();
  }
  return $raw;
}