StringNormalizer.php in JSON:API 8
File
tests/modules/jsonapi_test_field_type/src/Normalizer/StringNormalizer.php
View source
<?php
namespace Drupal\jsonapi_test_field_type\Normalizer;
use Drupal\Core\Field\Plugin\Field\FieldType\StringItem;
use Drupal\serialization\Normalizer\FieldItemNormalizer;
class StringNormalizer extends FieldItemNormalizer {
protected $supportedInterfaceOrClass = StringItem::class;
public function normalize($object, $format = NULL, array $context = []) {
$data = parent::normalize($object, $format, $context);
$data['value'] = str_replace('super', 'NOT', $data['value']);
return $data;
}
}
Classes
Name |
Description |
StringNormalizer |
Normalizes string fields, with a twist: it replaces 'super' with 'NOT'. |