-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #47 from superbrave/normalize-strategy
Added traversable normalization for the Exporter class
- Loading branch information
Showing
10 changed files
with
290 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
<?php | ||
/** | ||
* This file is part of the GDPR bundle. | ||
* | ||
* @category Bundle | ||
* @package Gdpr | ||
* @author SuperBrave <info@superbrave.nl> | ||
* @copyright 2018 SuperBrave <info@superbrave.nl> | ||
* @license https://github.com/superbrave/gdpr-bundle/blob/master/LICENSE MIT | ||
* @link https://www.superbrave.nl/ | ||
*/ | ||
|
||
namespace Superbrave\GdprBundle\Serializer\Normalizer; | ||
|
||
use Symfony\Component\Serializer\Normalizer\NormalizerAwareInterface; | ||
use Symfony\Component\Serializer\Normalizer\NormalizerAwareTrait; | ||
use Symfony\Component\Serializer\Normalizer\NormalizerInterface; | ||
|
||
/** | ||
* Normalizes data if it's iterable by calling the normalizer chain. | ||
* | ||
* @author Jelle van Oosterbosch <jvo@superbrave.nl> | ||
*/ | ||
class IterableNormalizer implements NormalizerInterface, NormalizerAwareInterface | ||
{ | ||
use NormalizerAwareTrait; | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function supportsNormalization($data, $format = null) | ||
{ | ||
if (is_array($data) || $data instanceof \Traversable) { | ||
return true; | ||
} | ||
|
||
return false; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function normalize($object, $format = null, array $context = array()) | ||
{ | ||
$normalizedData = []; | ||
|
||
foreach ($object as $value) { | ||
$normalizedData[] = $this->normalizer->normalize($value, $format, $context); | ||
} | ||
|
||
return $normalizedData; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"foo":"bar","baz":1,"qux":[],"quuxs":[{"foo":"bar","baz":1,"qux":[],"quuxs":[],"quuz":"2016-01-01T00:00:00+00:00","annotatedPropertyWithoutMethod":"Yes"},{"foo":"bar","baz":1,"qux":[],"quuxs":[],"quuz":"2016-01-01T00:00:00+00:00","annotatedPropertyWithoutMethod":"Yes"}],"quuz":"2016-01-01T00:00:00+00:00","annotatedPropertyWithoutMethod":"Yes"} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
["bar",1,[["2020-01-01T00:00:00+00:00","2020-01-01T00:00:00+00:00"]]] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
<?xml version="1.0"?> | ||
<mock><foo>bar</foo><baz>1</baz><qux/><quuxs><item key="0"><foo>bar</foo><baz>1</baz><qux/><quuxs/><annotatedPropertyWithoutMethod>Yes</annotatedPropertyWithoutMethod></item></quuxs><annotatedPropertyWithoutMethod>Yes</annotatedPropertyWithoutMethod></mock> | ||
<mock><foo>bar</foo><baz>1</baz><qux/><quuxs><foo>bar</foo><baz>1</baz><qux/><quuxs/><quuz>2016-01-01T00:00:00+00:00</quuz><annotatedPropertyWithoutMethod>Yes</annotatedPropertyWithoutMethod></quuxs><quuxs><foo>bar</foo><baz>1</baz><qux/><quuxs/><quuz>2016-01-01T00:00:00+00:00</quuz><annotatedPropertyWithoutMethod>Yes</annotatedPropertyWithoutMethod></quuxs><quuz>2016-01-01T00:00:00+00:00</quuz><annotatedPropertyWithoutMethod>Yes</annotatedPropertyWithoutMethod></mock> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.