2011-01-18 19:17:24 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Symfony\Component\Serializer;
|
|
|
|
|
2011-01-25 09:40:22 +00:00
|
|
|
use Symfony\Component\Serializer\Encoder\EncoderInterface;
|
2011-04-03 14:15:53 +01:00
|
|
|
use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
|
2011-01-25 09:40:22 +00:00
|
|
|
|
2011-01-18 19:17:24 +00:00
|
|
|
/*
|
|
|
|
* This file is part of the Symfony framework.
|
|
|
|
*
|
2011-03-06 11:40:06 +00:00
|
|
|
* (c) Fabien Potencier <fabien@symfony.com>
|
2011-01-18 19:17:24 +00:00
|
|
|
*
|
|
|
|
* This source file is subject to the MIT license that is bundled
|
|
|
|
* with this source code in the file LICENSE.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Defines the interface of the Serializer
|
|
|
|
*
|
|
|
|
* @author Jordi Boggiano <j.boggiano@seld.be>
|
|
|
|
*/
|
|
|
|
interface SerializerInterface
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* Serializes data in the appropriate format
|
|
|
|
*
|
|
|
|
* @param mixed $data any data
|
|
|
|
* @param string $format format name
|
|
|
|
* @return string
|
2011-04-03 14:49:40 +01:00
|
|
|
* @api
|
2011-01-18 19:17:24 +00:00
|
|
|
*/
|
|
|
|
function serialize($data, $format);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Normalizes any data into a set of arrays/scalars
|
|
|
|
*
|
|
|
|
* @param mixed $data data to normalize
|
|
|
|
* @param string $format format name, present to give the option to normalizers to act differently based on formats
|
|
|
|
* @return array|scalar
|
2011-04-03 14:49:40 +01:00
|
|
|
* @api
|
2011-01-18 19:17:24 +00:00
|
|
|
*/
|
|
|
|
function normalize($data, $format);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Normalizes an object into a set of arrays/scalars
|
|
|
|
*
|
|
|
|
* @param object $object object to normalize
|
|
|
|
* @param string $format format name, present to give the option to normalizers to act differently based on formats
|
|
|
|
* @param array $properties a list of properties to extract, if null all properties are returned
|
|
|
|
* @return array|scalar
|
|
|
|
*/
|
|
|
|
function normalizeObject($object, $format, $properties = null);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Denormalizes data back into an object of the given class
|
|
|
|
*
|
|
|
|
* @param mixed $data data to restore
|
|
|
|
* @param string $class the expected class to instantiate
|
|
|
|
* @param string $format format name, present to give the option to normalizers to act differently based on formats
|
|
|
|
* @return object
|
|
|
|
*/
|
|
|
|
function denormalizeObject($data, $class, $format = null);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Encodes data into the given format
|
|
|
|
*
|
|
|
|
* @param mixed $data data to encode
|
|
|
|
* @param string $format format name
|
|
|
|
* @return array|scalar
|
2011-04-03 14:49:40 +01:00
|
|
|
* @api
|
2011-01-18 19:17:24 +00:00
|
|
|
*/
|
|
|
|
function encode($data, $format);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Decodes a string from the given format back into PHP data
|
|
|
|
*
|
|
|
|
* @param string $data data to decode
|
|
|
|
* @param string $format format name
|
|
|
|
* @return mixed
|
2011-04-03 14:49:40 +01:00
|
|
|
* @api
|
2011-01-18 19:17:24 +00:00
|
|
|
*/
|
|
|
|
function decode($data, $format);
|
2011-01-25 09:40:22 +00:00
|
|
|
|
2011-04-03 14:15:53 +01:00
|
|
|
/**
|
|
|
|
* @param NormalizerInterface $normalizer
|
|
|
|
*/
|
|
|
|
function addNormalizer(NormalizerInterface $normalizer);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return array[]NormalizerInterface
|
|
|
|
*/
|
|
|
|
function getNormalizers();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param NormalizerInterface $normalizer
|
|
|
|
*/
|
|
|
|
function removeNormalizer(NormalizerInterface $normalizer);
|
|
|
|
|
2011-01-25 09:40:22 +00:00
|
|
|
/**
|
2011-04-23 16:05:44 +01:00
|
|
|
* @param string $format format name
|
2011-01-25 09:40:22 +00:00
|
|
|
* @param EncoderInterface $encoder
|
|
|
|
*/
|
2011-01-26 03:19:02 +00:00
|
|
|
function setEncoder($format, EncoderInterface $encoder);
|
2011-01-25 09:40:22 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @return EncoderInterface
|
|
|
|
*/
|
|
|
|
function getEncoders();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return array[]EncoderInterface
|
|
|
|
*/
|
|
|
|
function getEncoder($format);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Checks whether the serializer has an encoder registered for the given format
|
|
|
|
*
|
|
|
|
* @param string $format format name
|
|
|
|
* @return Boolean
|
|
|
|
*/
|
|
|
|
function hasEncoder($format);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param string $format format name
|
|
|
|
*/
|
|
|
|
function removeEncoder($format);
|
2011-01-18 19:17:24 +00:00
|
|
|
}
|