pradosoft / prado

Prado - Component Framework for PHP
Other
187 stars 70 forks source link

TComponent accepts anonymous behaviors (without names and renumbering numeric names) #917

Closed belisoful closed 1 year ago

belisoful commented 1 year ago

Yii implements anonymous behaviors that don't have names.

behaviors without names or that are numeric are renumber in the map (by the map) in Yii. PRADO could do the same thing by re-indexing behaviors without names or that are numeric.

TComponent needs to rename empty or numeric behavior names on attaching behaviors TComponent::attachClassBehavior needs to accept empty or numeric behaviors by renaming them as well. TBehaviorParameterLoader needs to handle empty or numeric behaviors as well by appending. TBehaviorModule, TComponent, TBehaviorParameterLoader needs to remove checks for behavior name.

This requires #915 to access the "getNextIntegerkey"

belisoful commented 1 year ago

I'm thinking about and looking at regression. Wakeup is going to mash class-wide IClassBehaviors when they don't have names. this could lead to adding the "same" anonymous behavior over and over being attached over and over. and numeric index of behavior names being found when they aren't the same.

Yii's anonymous behaviors persist over serialization.

Here is what we should be doing: all behaviors from before are saved and restored. IClassbehaviors that have a name and exist in the current request are replaced by the current instance rather than cloned (and the wakeup clone is simply dropped).

The way I wanted it to work is that a new class behaviors added between sleep and wakeup would be updated on the re-instanced component.

With anonymous behaviors, anonymous behaviors will be added and added and added when serialized/unserialized multiple times.

So, the old anonymous behavior should be retained on wake up, but new anonymous class behaviors are not added, but new named classes are added (because they can be tracked and replaced).

Yii doesn't have wakeup class behavior synchronization for new class behaviors.

belisoful commented 1 year ago

Ported this Yii concept to Prado. Done.