'\Drupal\Component\Serialization\YamlPecl::applyBooleanCallbacks', ]); restore_error_handler(); return $data; } /** * Handles errors for \Drupal\Component\Serialization\YamlPecl::decode(). * * @param int $severity * The severity level of the error. * @param string $message * The error message to display. * * @see \Drupal\Component\Serialization\YamlPecl::decode() */ public static function errorHandler($severity, $message) { restore_error_handler(); throw new InvalidDataTypeException($message, $severity); } /** * {@inheritdoc} */ public static function getFileExtension() { return 'yml'; } /** * Applies callbacks after parsing to ignore 1.1 style booleans. * * @param mixed $value * Value from YAML file. * @param string $tag * Tag that triggered the callback. * @param int $flags * Scalar entity style flags. * * @return string|bool * FALSE, false, TRUE and true are returned as booleans, everything else is * returned as a string. */ public static function applyBooleanCallbacks($value, $tag, $flags) { // YAML 1.1 spec dictates that 'Y', 'N', 'y' and 'n' are booleans. But, we // want the 1.2 behavior, so we only consider 'false', 'FALSE', 'true' and // 'TRUE' as booleans. if (!in_array(strtolower($value), ['false', 'true'], TRUE)) { return $value; } $map = [ 'false' => FALSE, 'true' => TRUE, ]; return $map[strtolower($value)]; } }