You are here

public function SerializationTestEncoder::encode in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/serialization/tests/serialization_test/src/SerializationTestEncoder.php \Drupal\serialization_test\SerializationTestEncoder::encode()

Encodes data into the given format.

Parameters

mixed $data Data to encode:

string $format Format name:

array $context options that normalizers/encoders have access to.:

Return value

scalar

Throws

UnexpectedValueException

Overrides EncoderInterface::encode

File

core/modules/serialization/tests/serialization_test/src/SerializationTestEncoder.php, line 24
Contains \Drupal\serialization_test\SerializationTestEncoder.

Class

SerializationTestEncoder

Namespace

Drupal\serialization_test

Code

public function encode($data, $format, array $context = array()) {

  // @see \Drupal\serialization_test\SerializationTestNormalizer::normalize().
  return 'Normalized by ' . $data['normalized_by'] . ', Encoded by SerializationTestEncoder';
}