class SerializationTestNormalizer

Same name in other branches
  1. 9 core/modules/serialization/tests/serialization_test/src/SerializationTestNormalizer.php \Drupal\serialization_test\SerializationTestNormalizer
  2. 8.9.x core/modules/serialization/tests/serialization_test/src/SerializationTestNormalizer.php \Drupal\serialization_test\SerializationTestNormalizer
  3. 11.x core/modules/serialization/tests/serialization_test/src/SerializationTestNormalizer.php \Drupal\serialization_test\SerializationTestNormalizer

Hierarchy

Expanded class hierarchy of SerializationTestNormalizer

2 string references to 'SerializationTestNormalizer'
SerializationTestNormalizer::normalize in core/modules/serialization/tests/serialization_test/src/SerializationTestNormalizer.php
serialization_test.services.yml in core/modules/serialization/tests/serialization_test/serialization_test.services.yml
core/modules/serialization/tests/serialization_test/serialization_test.services.yml
1 service uses SerializationTestNormalizer
serializer.normalizer.serialization_test in core/modules/serialization/tests/serialization_test/serialization_test.services.yml
Drupal\serialization_test\SerializationTestNormalizer

File

core/modules/serialization/tests/serialization_test/src/SerializationTestNormalizer.php, line 7

Namespace

Drupal\serialization_test
View source
class SerializationTestNormalizer implements NormalizerInterface {
    
    /**
     * The format that this Normalizer supports.
     *
     * @var string
     */
    protected static $format = 'serialization_test';
    
    /**
     * {@inheritdoc}
     */
    public function normalize($object, $format = NULL, array $context = []) : array|string|int|float|bool|\ArrayObject|null {
        $normalized = (array) $object;
        // Add identifying value that can be used to verify that the expected
        // normalizer was invoked.
        $normalized['normalized_by'] = 'SerializationTestNormalizer';
        return $normalized;
    }
    
    /**
     * {@inheritdoc}
     */
    public function supportsNormalization($data, ?string $format = NULL, array $context = []) : bool {
        return static::$format === $format;
    }
    
    /**
     * {@inheritdoc}
     */
    public function getSupportedTypes(?string $format) : array {
        return [
            \stdClass::class => TRUE,
        ];
    }

}

Members

Title Sort descending Modifiers Object type Summary
SerializationTestNormalizer::$format protected static property The format that this Normalizer supports.
SerializationTestNormalizer::getSupportedTypes public function
SerializationTestNormalizer::normalize public function
SerializationTestNormalizer::supportsNormalization public function

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.