Skip to content

Commit

Permalink
Merge branch 'fix-serializer-injection' into 'master'
Browse files Browse the repository at this point in the history
Fix dependency and add exclusion strategy to deserializer context

See merge request Coosos/versionworkflowbundle!16
  • Loading branch information
Coosos committed Nov 6, 2019
2 parents fd9caba + 9043923 commit a278ac2
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# 0.1.3

* Fix dependency injection for ``Coosos\VersionWorkflowBundle\EventListener\Doctrine\OnFlushListener``
* Add exclusion strategy to deserializer context

# 0.1.2

* Add Exclusion Strategy for exclude fields from VersionWorkflowTrait
Expand Down
2 changes: 0 additions & 2 deletions src/Resources/config/services.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,5 @@ services:
- { name: doctrine.event_listener, event: prePersist, priority: -1000 }

Coosos\VersionWorkflowBundle\EventListener\Doctrine\OnFlushListener:
arguments:
$serializer: '@jms_serializer.serializer'
tags:
- { name: doctrine.event_listener, event: onFlush }
6 changes: 5 additions & 1 deletion src/Service/SerializerService.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use Coosos\VersionWorkflowBundle\Serializer\Exclusion\FieldsListExclusionStrategy;
use Coosos\VersionWorkflowBundle\Utils\ClassContains;
use JMS\Serializer\DeserializationContext;
use JMS\Serializer\SerializationContext;
use JMS\Serializer\SerializerInterface;

Expand Down Expand Up @@ -66,6 +67,9 @@ public function serialize($data, $format = self::SERIALIZE_FORMAT)
*/
public function deserialize($data, $type, $format = self::SERIALIZE_FORMAT)
{
return $this->serializer->deserialize($data, $type, $format);
$context = (DeserializationContext::create())
->addExclusionStrategy(new FieldsListExclusionStrategy($this->classContains));

return $this->serializer->deserialize($data, $type, $format, $context);
}
}

0 comments on commit a278ac2

Please sign in to comment.