StringNormalizer.php in JSON:API 8
Same filename in this branch
Same filename and directory in other branches
Namespace
Drupal\jsonapi_test_data_type\NormalizerFile
tests/modules/jsonapi_test_data_type/src/Normalizer/StringNormalizer.phpView source
<?php
namespace Drupal\jsonapi_test_data_type\Normalizer;
use Drupal\Core\TypedData\Plugin\DataType\StringData;
use Drupal\serialization\Normalizer\NormalizerBase;
/**
* Normalizes string data, with a twist: it replaces 'super' with 'NOT'.
*/
class StringNormalizer extends NormalizerBase {
/**
* {@inheritdoc}
*/
protected $supportedInterfaceOrClass = StringData::class;
/**
* {@inheritdoc}
*/
public function normalize($object, $format = NULL, array $context = []) {
return str_replace('super', 'NOT', $object
->getValue());
}
}
Classes
Name![]() |
Description |
---|---|
StringNormalizer | Normalizes string data, with a twist: it replaces 'super' with 'NOT'. |