function BooleanNormalizer::denormalize
Same name in other branches
- 8.9.x core/modules/serialization/tests/modules/test_datatype_boolean_emoji_normalizer/src/Normalizer/BooleanNormalizer.php \Drupal\test_datatype_boolean_emoji_normalizer\Normalizer\BooleanNormalizer::denormalize()
- 10 core/modules/serialization/tests/modules/test_datatype_boolean_emoji_normalizer/src/Normalizer/BooleanNormalizer.php \Drupal\test_datatype_boolean_emoji_normalizer\Normalizer\BooleanNormalizer::denormalize()
- 11.x core/modules/serialization/tests/modules/test_datatype_boolean_emoji_normalizer/src/Normalizer/BooleanNormalizer.php \Drupal\test_datatype_boolean_emoji_normalizer\Normalizer\BooleanNormalizer::denormalize()
File
-
core/
modules/ serialization/ tests/ modules/ test_datatype_boolean_emoji_normalizer/ src/ Normalizer/ BooleanNormalizer.php, line 29
Class
- BooleanNormalizer
- Normalizes boolean data weirdly: renders them as 👍 (TRUE) or 👎 (FALSE).
Namespace
Drupal\test_datatype_boolean_emoji_normalizer\NormalizerCode
public function denormalize($data, $class, $format = NULL, array $context = []) {
if (!in_array($data, [
'👍',
'👎',
], TRUE)) {
throw new \UnexpectedValueException('Only 👍 and 👎 are acceptable values.');
}
return $data === '👍';
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.