minor #23241 [Serializer] Implement missing context aware interfaces (chalasr)
This PR was merged into the 4.0-dev branch.
Discussion
----------
[Serializer] Implement missing context aware interfaces
| Q | A
| ------------- | ---
| Branch? | 4.0
| Bug fix? | no
| New feature? | no
| BC breaks? | no
| Deprecations? | no
| Tests pass? | yes
| Fixed tickets | https://github.com/symfony/symfony/pull/22743
| License | MIT
| Doc PR | n/a
Forgot in https://github.com/symfony/symfony/pull/22743
Commits
-------
61d796a2ea
[Serializer] Implement missing context aware interfaces
This commit is contained in:
commit
407631c682
@ -22,7 +22,7 @@ use Symfony\Component\Serializer\Exception\RuntimeException;
|
||||
*
|
||||
* @final since version 3.3.
|
||||
*/
|
||||
class ChainDecoder implements DecoderInterface /*, ContextAwareDecoderInterface*/
|
||||
class ChainDecoder implements ContextAwareDecoderInterface
|
||||
{
|
||||
protected $decoders = array();
|
||||
protected $decoderByFormat = array();
|
||||
@ -43,10 +43,8 @@ class ChainDecoder implements DecoderInterface /*, ContextAwareDecoderInterface*
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function supportsDecoding($format/*, array $context = array()*/)
|
||||
public function supportsDecoding($format, array $context = array())
|
||||
{
|
||||
$context = func_num_args() > 1 ? func_get_arg(1) : array();
|
||||
|
||||
try {
|
||||
$this->getDecoder($format, $context);
|
||||
} catch (RuntimeException $e) {
|
||||
|
@ -22,7 +22,7 @@ use Symfony\Component\Serializer\Exception\RuntimeException;
|
||||
*
|
||||
* @final since version 3.3.
|
||||
*/
|
||||
class ChainEncoder implements EncoderInterface /*, ContextAwareEncoderInterface*/
|
||||
class ChainEncoder implements ContextAwareEncoderInterface
|
||||
{
|
||||
protected $encoders = array();
|
||||
protected $encoderByFormat = array();
|
||||
@ -43,10 +43,8 @@ class ChainEncoder implements EncoderInterface /*, ContextAwareEncoderInterface*
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function supportsEncoding($format/*, array $context = array()*/)
|
||||
public function supportsEncoding($format, array $context = array())
|
||||
{
|
||||
$context = func_num_args() > 1 ? func_get_arg(1) : array();
|
||||
|
||||
try {
|
||||
$this->getEncoder($format, $context);
|
||||
} catch (RuntimeException $e) {
|
||||
@ -64,9 +62,8 @@ class ChainEncoder implements EncoderInterface /*, ContextAwareEncoderInterface*
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function needsNormalization($format/*, array $context = array()*/)
|
||||
public function needsNormalization($format, array $context = array())
|
||||
{
|
||||
$context = func_num_args() > 1 ? func_get_arg(1) : array();
|
||||
$encoder = $this->getEncoder($format, $context);
|
||||
|
||||
if (!$encoder instanceof NormalizationAwareInterface) {
|
||||
|
@ -24,7 +24,7 @@ use Symfony\Component\Serializer\SerializerInterface;
|
||||
*
|
||||
* @final since version 3.3.
|
||||
*/
|
||||
class ArrayDenormalizer implements DenormalizerInterface, SerializerAwareInterface
|
||||
class ArrayDenormalizer implements ContextAwareDenormalizerInterface, SerializerAwareInterface
|
||||
{
|
||||
/**
|
||||
* @var SerializerInterface|DenormalizerInterface
|
||||
@ -66,10 +66,8 @@ class ArrayDenormalizer implements DenormalizerInterface, SerializerAwareInterfa
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function supportsDenormalization($data, $type, $format = null/*, array $context = array()*/)
|
||||
public function supportsDenormalization($data, $type, $format = null, array $context = array())
|
||||
{
|
||||
$context = func_num_args() > 3 ? func_get_arg(3) : array();
|
||||
|
||||
return substr($type, -2) === '[]'
|
||||
&& $this->serializer->supportsDenormalization($data, substr($type, 0, -2), $format, $context);
|
||||
}
|
||||
|
@ -13,8 +13,12 @@ namespace Symfony\Component\Serializer;
|
||||
|
||||
use Symfony\Component\Serializer\Encoder\ChainDecoder;
|
||||
use Symfony\Component\Serializer\Encoder\ChainEncoder;
|
||||
use Symfony\Component\Serializer\Encoder\ContextAwareDecoderInterface;
|
||||
use Symfony\Component\Serializer\Encoder\ContextAwareEncoderInterface;
|
||||
use Symfony\Component\Serializer\Encoder\EncoderInterface;
|
||||
use Symfony\Component\Serializer\Encoder\DecoderInterface;
|
||||
use Symfony\Component\Serializer\Normalizer\ContextAwareDenormalizerInterface;
|
||||
use Symfony\Component\Serializer\Normalizer\ContextAwareNormalizerInterface;
|
||||
use Symfony\Component\Serializer\Normalizer\DenormalizerAwareInterface;
|
||||
use Symfony\Component\Serializer\Normalizer\NormalizerAwareInterface;
|
||||
use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
|
||||
@ -37,7 +41,7 @@ use Symfony\Component\Serializer\Exception\UnexpectedValueException;
|
||||
* @author Lukas Kahwe Smith <smith@pooteeweet.org>
|
||||
* @author Kévin Dunglas <dunglas@gmail.com>
|
||||
*/
|
||||
class Serializer implements SerializerInterface, NormalizerInterface, DenormalizerInterface, EncoderInterface, DecoderInterface
|
||||
class Serializer implements SerializerInterface, ContextAwareNormalizerInterface, ContextAwareDenormalizerInterface, ContextAwareEncoderInterface, ContextAwareDecoderInterface
|
||||
{
|
||||
/**
|
||||
* @var Encoder\ChainEncoder
|
||||
|
Reference in New Issue
Block a user