You are here

protected function JmesPathParser::formatSyntaxError in Feeds extensible parsers 8

Formats a syntax error message with HTML.

A syntax error message can be for example:


items[].join(`__`,[title,description)
                                    ^

Parameters

string $message: The message to format.

Return value

string The HTML formatted message.

1 call to JmesPathParser::formatSyntaxError()
JmesPathParser::validateExpression in src/Feeds/Parser/JmesPathParser.php
Validates an expression.

File

src/Feeds/Parser/JmesPathParser.php, line 198

Class

JmesPathParser
Defines a JSON parser using JMESPath.

Namespace

Drupal\feeds_ex\Feeds\Parser

Code

protected function formatSyntaxError($message) {
  $message = trim($message);
  $message = nl2br($message);

  // Spaces in the error message can be used to point to a specific
  // character in the line above.
  $message = str_replace('  ', '  ', $message);

  // Remove newlines to make testing easier.
  $message = str_replace("\n", '', $message);

  // Return the message between <pre>-tags so that the error message can be
  // displayed correctly. Else the double spaces may not get displayed.
  return '<pre>' . $message . '</pre>';
}