[Serializer] Fix CustomNormalizer supportsDenormalization interface check.
This commit is contained in:
parent
459942b456
commit
e647eaa646
@ -59,6 +59,6 @@ class CustomNormalizer extends SerializerAwareNormalizer implements NormalizerIn
|
|||||||
{
|
{
|
||||||
$class = new \ReflectionClass($type);
|
$class = new \ReflectionClass($type);
|
||||||
|
|
||||||
return $class->isSubclassOf('Symfony\Component\Serializer\Normalizer\NormalizableInterface');
|
return $class->isSubclassOf('Symfony\Component\Serializer\Normalizer\DenormalizableInterface');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,25 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of the Symfony package.
|
||||||
|
*
|
||||||
|
* (c) Fabien Potencier <fabien@symfony.com>
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Symfony\Component\Serializer\Tests\Fixtures;
|
||||||
|
|
||||||
|
use Symfony\Component\Serializer\Normalizer\DenormalizableInterface;
|
||||||
|
use Symfony\Component\Serializer\Normalizer\DenormalizerInterface;
|
||||||
|
|
||||||
|
class DenormalizableDummy implements DenormalizableInterface
|
||||||
|
{
|
||||||
|
|
||||||
|
function denormalize(DenormalizerInterface $denormalizer, $data, $format = null)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -12,10 +12,11 @@
|
|||||||
namespace Symfony\Component\Serializer\Tests\Fixtures;
|
namespace Symfony\Component\Serializer\Tests\Fixtures;
|
||||||
|
|
||||||
use Symfony\Component\Serializer\Normalizer\NormalizableInterface;
|
use Symfony\Component\Serializer\Normalizer\NormalizableInterface;
|
||||||
|
use Symfony\Component\Serializer\Normalizer\DenormalizableInterface;
|
||||||
use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
|
use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
|
||||||
use Symfony\Component\Serializer\Normalizer\DenormalizerInterface;
|
use Symfony\Component\Serializer\Normalizer\DenormalizerInterface;
|
||||||
|
|
||||||
class Dummy implements NormalizableInterface
|
class Dummy implements NormalizableInterface, DenormalizableInterface
|
||||||
{
|
{
|
||||||
public $foo;
|
public $foo;
|
||||||
public $bar;
|
public $bar;
|
||||||
|
@ -12,10 +12,11 @@
|
|||||||
namespace Symfony\Component\Serializer\Tests\Fixtures;
|
namespace Symfony\Component\Serializer\Tests\Fixtures;
|
||||||
|
|
||||||
use Symfony\Component\Serializer\Normalizer\NormalizableInterface;
|
use Symfony\Component\Serializer\Normalizer\NormalizableInterface;
|
||||||
|
use Symfony\Component\Serializer\Normalizer\DenormalizableInterface;
|
||||||
use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
|
use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
|
||||||
use Symfony\Component\Serializer\Normalizer\DenormalizerInterface;
|
use Symfony\Component\Serializer\Normalizer\DenormalizerInterface;
|
||||||
|
|
||||||
class NormalizableTraversableDummy extends TraversableDummy implements NormalizableInterface
|
class NormalizableTraversableDummy extends TraversableDummy implements NormalizableInterface, DenormalizableInterface
|
||||||
{
|
{
|
||||||
public function normalize(NormalizerInterface $normalizer, $format = null)
|
public function normalize(NormalizerInterface $normalizer, $format = null)
|
||||||
{
|
{
|
||||||
|
@ -53,5 +53,6 @@ class CustomNormalizerTest extends \PHPUnit_Framework_TestCase
|
|||||||
{
|
{
|
||||||
$this->assertTrue($this->normalizer->supportsDenormalization(array(), 'Symfony\Component\Serializer\Tests\Fixtures\ScalarDummy'));
|
$this->assertTrue($this->normalizer->supportsDenormalization(array(), 'Symfony\Component\Serializer\Tests\Fixtures\ScalarDummy'));
|
||||||
$this->assertFalse($this->normalizer->supportsDenormalization(array(), 'stdClass'));
|
$this->assertFalse($this->normalizer->supportsDenormalization(array(), 'stdClass'));
|
||||||
|
$this->assertTrue($this->normalizer->supportsDenormalization(array(), 'Symfony\Component\Serializer\Tests\Fixtures\DenormalizableDummy'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user