function _yamlform_entity_element_validate_rendering_error_handler in YAML Form 8
Provides custom PHP error handling when form rendering is validated.
Converts E_RECOVERABLE_ERROR to WARNING so that an exceptions can be thrown and caught by \Drupal\yamlform\YamlFormEntityElementsValidator::validateRendering().
Parameters
int $error_level: The level of the error raised.
string $message: The error message.
string $filename: The filename that the error was raised in.
int $line: The line number the error was raised at.
array $context: 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\yamlform\YamlFormEntityElementsValidator::validateRendering()
2 string references to '_yamlform_entity_element_validate_rendering_error_handler'
- TextBase::validateConfigurationForm in src/
Plugin/ YamlFormElement/ TextBase.php - Form validation handler.
- YamlFormEntityElementsValidator::validateRendering in src/
YamlFormEntityElementsValidator.php - Validate that elements are a valid render array.
File
- ./
yamlform.module, line 597 - Enables the creation of forms and questionnaires.
Code
function _yamlform_entity_element_validate_rendering_error_handler($error_level, $message, $filename, $line, array $context) {
// 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($message, $message, $filename, $line, $context);
}
}