Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. Serializer.php

function Serializer::serialize

Overrides SerializerInterface::serialize

File

vendor/symfony/serializer/Serializer.php, line 122

Class

Serializer
Serializer serializes and deserializes data.

Namespace

Symfony\Component\Serializer

Code

public final function serialize(mixed $data, string $format, array $context = []) : string {
    if (!$this->supportsEncoding($format, $context)) {
        throw new UnsupportedFormatException(\sprintf('Serialization for the format "%s" is not supported.', $format));
    }
    if ($this->encoder
        ->needsNormalization($format, $context)) {
        $data = $this->normalize($data, $format, $context);
    }
    return $this->encode($data, $format, $context);
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal