SerializationTestEncoder.php

Same filename in other branches
  1. 9 core/modules/serialization/tests/serialization_test/src/SerializationTestEncoder.php
  2. 10 core/modules/serialization/tests/serialization_test/src/SerializationTestEncoder.php
  3. 11.x core/modules/serialization/tests/serialization_test/src/SerializationTestEncoder.php

Namespace

Drupal\serialization_test

File

core/modules/serialization/tests/serialization_test/src/SerializationTestEncoder.php

View source
<?php

namespace Drupal\serialization_test;

use Symfony\Component\Serializer\Encoder\EncoderInterface;
class SerializationTestEncoder implements EncoderInterface {
    
    /**
     * The format that this Encoder supports.
     *
     * @var string
     */
    protected static $format = 'serialization_test';
    
    /**
     * {@inheritdoc}
     */
    public function encode($data, $format, array $context = []) {
        // @see \Drupal\serialization_test\SerializationTestNormalizer::normalize().
        return 'Normalized by ' . $data['normalized_by'] . ', Encoded by SerializationTestEncoder';
    }
    
    /**
     * {@inheritdoc}
     */
    public function supportsEncoding($format) {
        return static::$format === $format;
    }

}

Classes

Title Deprecated Summary
SerializationTestEncoder

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