I’ve just started working in Yii and I’m trying to add some functionality to the CClientScript, before beginning overriding functions I’m trying to understand everything it’s doing so I don’t trip myself up later by not including something or including it wrong.
I’ve spotted a method call when registering scripts/files:
I’ve followed this chain down through a few classes to COutputCache in one case and seen the replayActions function. What is this used for? Is there any thing that requires this or is it as my suspicions and it’s just a useful debugging feature to track caching?
Why are caching actions recorded for later replaying?
The comment in recordCachingAction in CClientScript says: " Records a method call when an output cache is in effect." When you follow execution workflow, you’ll find that in CController the action is only recorded if there’s something on the caching stack. In COutputCache you’ll find that the widget pushes itself on that stack in init() and removes itself afterwards in run(). So no other script registrations outside will get cached (except there’s a nested fragment).
I think the reason why this is not documented is because it are really internals of how Yii tries to be as smart as possible and just make things work. So you often have to read the code when you want to find out how it works under the hood. But i agree that even that is sometimes a bit hard. But if you add it to the docs, most users will just get confused, as they don’t need this extra information.