You are here

class StringNormalizer in JSON:API 8

Same name in this branch
  1. 8 tests/modules/jsonapi_test_data_type/src/Normalizer/StringNormalizer.php \Drupal\jsonapi_test_data_type\Normalizer\StringNormalizer
  2. 8 tests/modules/jsonapi_test_field_type/src/Normalizer/StringNormalizer.php \Drupal\jsonapi_test_field_type\Normalizer\StringNormalizer
Same name and namespace in other branches
  1. 8.2 tests/modules/jsonapi_test_data_type/src/Normalizer/StringNormalizer.php \Drupal\jsonapi_test_data_type\Normalizer\StringNormalizer

Normalizes string data, with a twist: it replaces 'super' with 'NOT'.

Hierarchy

Expanded class hierarchy of StringNormalizer

1 string reference to 'StringNormalizer'
jsonapi_test_data_type.services.yml in tests/modules/jsonapi_test_data_type/jsonapi_test_data_type.services.yml
tests/modules/jsonapi_test_data_type/jsonapi_test_data_type.services.yml
1 service uses StringNormalizer
serializer.normalizer.string.jsonapi_test_data_type in tests/modules/jsonapi_test_data_type/jsonapi_test_data_type.services.yml
Drupal\jsonapi_test_data_type\Normalizer\StringNormalizer

File

tests/modules/jsonapi_test_data_type/src/Normalizer/StringNormalizer.php, line 11

Namespace

Drupal\jsonapi_test_data_type\Normalizer
View source
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());
  }

}

Members

Namesort descending Modifiers Type Description Overrides
CacheableNormalizerInterface::SERIALIZATION_CONTEXT_CACHEABILITY constant Name of key for bubbling cacheability metadata via serialization context.
NormalizerBase::$format protected property List of formats which supports (de-)normalization. 3
NormalizerBase::addCacheableDependency protected function Adds cacheability if applicable.
NormalizerBase::checkFormat protected function Checks if the provided format is supported by this normalizer. 2
NormalizerBase::supportsDenormalization public function Implements \Symfony\Component\Serializer\Normalizer\DenormalizerInterface::supportsDenormalization() 1
NormalizerBase::supportsNormalization public function Checks whether the given class is supported for normalization by this normalizer. 1
StringNormalizer::$supportedInterfaceOrClass protected property The interface or class that this Normalizer supports. Overrides NormalizerBase::$supportedInterfaceOrClass
StringNormalizer::normalize public function Normalizes an object into a set of arrays/scalars.