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.
Allows declaring output groups on columns and foreign key relations in schema.xml. Passing a group name to the
toOutputGroup()
method on the model or ObjectCollection returns an array holding all values defined by the group name.Usage
Declare groups in schema.xml:
Serialize objects by output group:
Instead of a group name, an array with model class names can also be used. In this form, multiple groups can be given in an array:
Default output groups per table
Default output groups can be defined on the table, columns and relations can opt-out with
ignoreGroup
orrefIgnoreGroup
:Avoids recursion
Related model instances are linked in both directions, leading to recursive output when using
toArray()
. Output groups skip relations that were already handled:Implementation
Changes are implemented as a behavior, so this is an opt-in, and the code does not interfere with Propel code.
To enable output groups, the behavior has to be declared in schema.xml:
The behavior adds functionality to table map, model and query classes:
TableMap classes:
TableMap::getCollectionClassName()
, so queries use a subclass of ObjectCollection with atoOutputGroup()
method. If necessary, the class can be set manually through the behavior'sobject_collection_class
parameter.Model classes:
toOutputGroup()
method to generated model classes.Query classes:
@method
declarations with updated return type for thefindX()
methods to header doc.I find this much easier than using a serializer as I don't have to re-iterate all columns in another file.