You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The PropertyPath class currently makes a list of assumptions:
1. Objects are treated by reference
When the path author.name is modified, the following methods are called:
getAuthor()
setName() // on the author
Note that setAuthor() is not called.
2. Adders and removers are used if they exist
If a collection is written into the path tags and the methods addTag() and removeTag() exist, these are used to merge into the old collection instead of accessing the old collection directly via its ArrayAccess interface. The following methods are called:
getTags()
addTag(...) // instead of $tags[] = ...
removeTag(...) // instead of unset($tags[...])
3. Adders and removers follow English singularization rules
If a property path is called children, the guessed adders and removers are addChild() and removeChild().
Limitations
The above assumptions do not hold in all applications:
The
PropertyPathclass currently makes a list of assumptions:1. Objects are treated by reference
When the path
author.nameis modified, the following methods are called:Note that
setAuthor()is not called.2. Adders and removers are used if they exist
If a collection is written into the path
tagsand the methodsaddTag()andremoveTag()exist, these are used to merge into the old collection instead of accessing the old collection directly via itsArrayAccessinterface. The following methods are called:3. Adders and removers follow English singularization rules
If a property path is called
children, the guessed adders and removers areaddChild()andremoveChild().Limitations
The above assumptions do not hold in all applications:
So, these assumptions should be made configurable. The challenge is how to build this API in an intuitive way.
Alternative 1: Option arrays
The first alternative is to pass the options in an array separately from the property path. For example:
Alternative 2: Path flags
The second alternative is to build the configuration options into the path:
Alternative 3: Your suggestions
Do you have any other ideas? What approach do you prefer?