Skip to content
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

Allow Post Serialize Event to overwrite existing data #273

Merged
merged 4 commits into from
Sep 9, 2016

Conversation

jockri
Copy link
Contributor

@jockri jockri commented May 15, 2014

The GenericSerializationVisitor throws an exception when trying to add a data field that already exists. This PR makes it possible to change existing data for serialization purposes by adding the replaceData method.

Solves issue: #129

@stof
Copy link
Contributor

stof commented May 15, 2014

this will not be very useful without a way to know whether you have the data already to choose between add and replace. IMO, replace should not check whether the data is already there (you don't really care as it would be data being dropped anyway)

@jockri
Copy link
Contributor Author

jockri commented May 15, 2014

@stof Indeed you are right, I have removed the check.

* Allows you to replace existing data on the current object/root element.
*
* @param string $key
* @param scalar|array $value This value must either be a regular scalar, or an array.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

scalar|array|null would be better (null is not a scalar in PHP)

@jockri
Copy link
Contributor Author

jockri commented May 15, 2014

I copied the docblock from the addData method... I have added the null option for both methods now.

@bezhermoso
Copy link

I'm curious if this is still being actively pursued? :)

@jockri
Copy link
Contributor Author

jockri commented Jul 1, 2014

@schmittjoh Can you please take a look at my PR and give some feedback or merge it? Thx!

@kimausloos
Copy link

It would be nice if this is in, currently we use the fork because we need it...

@jverdeyen
Copy link

👍

2 similar comments
@Devolicious
Copy link

👍

@thomasmeeus
Copy link

👍

@jsampedro77
Copy link

👍 Really useful

@joseandrespg
Copy link

👍

@jockri
Copy link
Contributor Author

jockri commented Jun 11, 2015

@schmittjoh Can you review this PR? Thx

@piotrantosik
Copy link

👍

1 similar comment
@philmoreau
Copy link

+1

@goetas goetas added the To Merge label Aug 9, 2016
@goetas goetas added this to the v1.4 milestone Aug 9, 2016
* master: (77 commits)
  use explicit boolean comparison
  Added tests to ensure SerializeNull policy
  Revert "Default `$serializeNull` to false"
  Start with the 1.3.x branch
  Added tests for 'hasData'
  $context is not used
  Fix Doctrine PHPCR ODM 2.0 compatibility
  Start with the 1.2.x branch
  added hhvm-nightly
  Make tests working on HHVM
  Use camel case for skipWhenEmpty annotation
  Lookup for local namespaces when creating elements
  Use always xpath to find nodes, when the namespace is empty, simplexml fails
  Allow to decide when skip empty arrays when serializing to xml
  Added skip_when_empty xml collection option
  Do not skip empty not inline array root node
  Allow to use custom serializer with primitive type
  Composer is not able to resolve a dependency
  Fix xml-attribute-map for the xml driver
  makes sure that explicit lists are serialized as lists
  ...
@jockri
Copy link
Contributor Author

jockri commented Sep 1, 2016

@goetas I have merged the master branch again, so you can merge this PR.

@goetas
Copy link
Collaborator

goetas commented Sep 9, 2016

@jockri tnx!

@goetas goetas merged commit 447c7d3 into schmittjoh:master Sep 9, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.