8000 [Serializer] split off an EncoderInterface and NormalizerInterface from SerializerInte by lsmith77 · Pull Request #2530 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[Serializer] split off an EncoderInterface and NormalizerInterface from SerializerInte #2530

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 16 commits into from
Dec 14, 2011
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
require a (de)normalizer inside the (de)normalizable interfaces inste…
…ad of a serializer
  • Loading branch information
lsmith77 committed Dec 11, 2011
commit 351eaa8506410824478c9539c34f60c55f51eaf0
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

namespace Symfony\Component\Serializer\Normalizer;

use Symfony\Component\Serializer\SerializerInterface;

/*
* This file is part of the Symfony framework.
*
Expand All @@ -29,11 +27,11 @@ interface DenormalizableInterface
* It is important to understand that the normalize() call should denormalize
* recursively all child objects of the implementor.
*
* @param SerializerInterface $serializer The serializer is given so that you
* @param DenormalizerInterface $denormalizer The denormalizer is given so that you
* can use it to denormalize objects contained within this object.
* @param array|scalar $data The data from which to re-create the object.
* @param string|null $format The format is optionally given to be able to denormalize differently
* based on different input formats.
*/
function denormalize(SerializerInterface $serializer, $data, $format = null);
function denormalize(DenormalizerInterface $denormalizer, $data, $format = null);
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

namespace Symfony\Component\Serializer\Normalizer;

use Symfony\Component\Serializer\SerializerInterface;

/*
* This file is part of the Symfony framework.
*
Expand All @@ -29,11 +27,11 @@ interface NormalizableInterface
* It is important to understand that the normalize() call should normalize
* recursively all child objects of the implementor.
*
* @param SerializerInterface $serializer The serializer is given so that you
* @param NormalizerInterface $normalizer The normalizer is given so that you
* can use it to normalize objects contained within this object.
* @param string|null $format The format is optionally given to be able to normalize differently
* based on different output formats.
* @return array|scalar
*/
function normalize(SerializerInterface $serializer, $format = null);
function normalize(NormalizerInterface $normalizer, $format = null);
}
7 changes: 4 additions & 3 deletions tests/Symfony/Tests/Component/Serializer/Fixtures/Dummy.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
namespace Symfony\Tests\Component\Serializer\Fixtures;

use Symfony\Component\Serializer\Normalizer\NormalizableInterface;
use Symfony\Component\Serializer\SerializerInterface;
use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
use Symfony\Component\Serializer\Normalizer\DenormalizerInterface;

class Dummy implements NormalizableInterface
{
Expand All @@ -12,7 +13,7 @@ class Dummy implements NormalizableInterface
public $baz;
public $qux;

public function normalize(SerializerInterface $serializer, $format = null)
public function normalize(NormalizerInterface $normalizer, $format = null)
{
return array(
'foo' => $this->foo,
Expand All @@ -22,7 +23,7 @@ public function normalize(SerializerInterface $serializer, $format = null)
);
}

public function denormalize(SerializerInterface $serializer, $data, $format = null)
public function denormalize(DenormalizerInterface $denormalizer, $data, $format = null)
{
$this->foo = $data['foo'];
$this->bar = $data['bar'];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,20 @@
namespace Symfony\Tests\Component\Serializer\Fixtures;

use Symfony\Component\Serializer\Normalizer\NormalizableInterface;
use Symfony\Component\Serializer\SerializerInterface;
use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
use Symfony\Component\Serializer\Normalizer\DenormalizerInterface;

class ScalarDummy implements NormalizableInterface
{
public $foo;
public $xmlFoo;

public function normalize(SerializerInterface $serializer, $format = null)
public function normalize(NormalizerInterface $normalizer, $format = null)
{
return $format === 'xml' ? $this->xmlFoo : $this->foo;
}

public function denormalize(SerializerInterface $serializer, $data, $format = null)
public function denormalize(DenormalizerInterface $denormalizer, $data, $format = null)
{
if ($format === 'xml') {
$this->xmlFoo = $data;
Expand Down
0