You are here

function _webform_entity_element_validate_rendering_error_handler in Webform 6.x

Same name and namespace in other branches
  1. 8.5 webform.module \_webform_entity_element_validate_rendering_error_handler()

Provides custom PHP error handling when webform rendering is validated.

Converts E_RECOVERABLE_ERROR to WARNING so that an exceptions can be thrown and caught by \Drupal\webform\WebformEntityElementsValidator::validateRendering().

Parameters

int $error_level: The level of the error raised.

string $message: The error message.

string $filename: (optional) The filename that the error was raised in.

string $line: (optional) The line number the error was raised at.

array $context: (optional) An array that points to the active symbol table at the point the error occurred.

Throws

\ErrorException Throw ErrorException for E_RECOVERABLE_ERROR errors.

See also

\Drupal\webform\WebformEntityElementsValidator::validateRendering()

2 string references to '_webform_entity_element_validate_rendering_error_handler'
TextBase::validateConfigurationForm in src/Plugin/WebformElement/TextBase.php
Form validation handler.
WebformEntityElementsValidator::validateRendering in src/WebformEntityElementsValidator.php
Validate that elements are a valid render array.

File

./webform.module, line 1052
Enables the creation of webforms and questionnaires.

Code

function _webform_entity_element_validate_rendering_error_handler($error_level, $message, $filename = NULL, $line = NULL, $context = NULL) {

  // From: http://stackoverflow.com/questions/15461611/php-try-catch-not-catching-all-exceptions
  if (E_RECOVERABLE_ERROR === $error_level) {

    // Allow Drupal to still log the error but convert it to a warning.
    _drupal_error_handler(E_WARNING, $message, $filename, $line, $context);
    throw new ErrorException($message, $error_level, 0, $filename, $line);
  }
  else {
    _drupal_error_handler($error_level, $message, $filename, $line, $context);
  }
}