public static YamlPecl::decode($raw)
Decodes data from the serialization format.
Parameters
string $raw: The raw data string to decode.
Return value
mixed The decoded data.
Overrides SerializationInterface::decode
File
- core/lib/Drupal/Component/Serialization/YamlPecl.php, line 29
Class
- YamlPecl
- Provides default serialization for YAML using the PECL extension.
Namespace
Drupal\Component\Serialization
Code
public static function decode($raw) { // yaml_parse() will error with an empty value. if (!trim($raw)) { return NULL; } // @todo Use ErrorExceptions when https://drupal.org/node/1247666 is in. // yaml_parse() will throw errors instead of raising an exception. Until // such time as Drupal supports native PHP ErrorExceptions as the error // handler, we need to temporarily set the error handler as ::errorHandler() // and then restore it after decoding has occurred. This allows us to turn // parsing errors into a throwable exception. // @see Drupal\Component\Serialization\Exception\InvalidDataTypeException // @see http://php.net/manual/en/class.errorexception.php set_error_handler([__CLASS__, 'errorHandler']); $ndocs = 0; $data = yaml_parse($raw, 0, $ndocs, [ YAML_BOOL_TAG => '\Drupal\Component\Serialization\YamlPecl::applyBooleanCallbacks', ]); restore_error_handler(); return $data; }
Please login to continue.