Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
Make export of objects customizable #56
Make export of objects customizable #56
Changes from all commits
2645ed6
f642cd3
af726e4
a05140e
f8faf8a
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
one more thing I just noticed.
the
$class . ' Object #'
prefix will only be present in "root objects". in custom object exporters this$class . ' Object #'
format needs to be replicated, even if the custom exporter delegates export back to the built-in one.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we deal with that in
Exporter::exportObject()
or should we trust implementors of custom object exporters to do the right thing?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see a way how
Exporter::exportObject()
could do that in a way which would even work when custom exporters would delegate exporting of some stuff back to the exporter object.Maybe we just need a test-case so we can see whether it works already or what a custom ObjectExporter needs todo to get it right
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe the problem would be less theoretic if we try to implement a real world exporter
Maybe @BladeMF could try his use-case..?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like that ... and would rather not make a release without this feature having been validated through real world use cases.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@BladeMF ping
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@BladeMF Can you help us?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, missed it in April. Let me have a look.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, we can try some pseudo-code first and see where that takes us, OK?
So, if I was to write a Doctrine entity exporter the case might be something like the following. A typical entity object graph might look like this (the notation is
(<class-name>)#<instance-name>
for classes and then<property-type> $<property-name>: <property-value>
, the below is taken from a recent object but simplified):so the exporter code would be something like this:
the
formatExport
function might look something as silly as:It appears that a
formatExport
function is needed. I think the purpose of the custom exporter is just to export a specific class, nothing more, nothing less. It should defer anything else to the default exporter. I am not even sure theformatExport
function is in the Exporter, it looks like a separate formatter class may be needed, but I won't die on that hill. I also kind of dislike the need for me to deal with the indent before the closing brace)
, because it's mine-1, but I don't really know that, because the default formatter/exporter determines that, if that makes sense.If the above (a bit messy) code is not convincing I could try and write one for real.
I am in the middle of moving to the seaside for 3 months, but I will try and think more about that code. It may very well be the case that I need to write one real.