[Serializer] Unset attributes when creating child context
This commit is contained in:
parent
c9f72e2807
commit
4ff9d99f23
@ -402,6 +402,8 @@ abstract class AbstractNormalizer extends SerializerAwareNormalizer implements N
|
||||
{
|
||||
if (isset($parentContext[self::ATTRIBUTES][$attribute])) {
|
||||
$parentContext[self::ATTRIBUTES] = $parentContext[self::ATTRIBUTES][$attribute];
|
||||
} else {
|
||||
unset($parentContext[self::ATTRIBUTES]);
|
||||
}
|
||||
|
||||
return $parentContext;
|
||||
|
@ -673,6 +673,16 @@ class ObjectNormalizerTest extends TestCase
|
||||
),
|
||||
$serializer->normalize($objectDummy, null, $context)
|
||||
);
|
||||
|
||||
$context = array('attributes' => array('foo', 'baz', 'object'));
|
||||
$this->assertEquals(
|
||||
array(
|
||||
'foo' => 'foo',
|
||||
'baz' => true,
|
||||
'object' => array('foo' => 'innerFoo', 'bar' => 'innerBar'),
|
||||
),
|
||||
$serializer->normalize($objectDummy, null, $context)
|
||||
);
|
||||
}
|
||||
|
||||
public function testAttributesContextDenormalize()
|
||||
|
Reference in New Issue
Block a user