cubecart / v6

CubeCart Version 6
https://cubecart.com
72 stars 59 forks source link

Code Review: Adding/Changing Phrase via Hook #3464

Open bhsmither opened 8 months ago

bhsmither commented 8 months ago

With the ultimate goal of getting a new phrase, or more to the point, a changed phrase into Smarty's variable LANG, specifically via hook or snippet code, the specific step Language->assignLang() seems to be required each and every time Language->_language_strings is modified.

Currently, assignLang() is called via Language->setTemplate(), relatively early, before many locations where hooks load.

I am experimenting with moving assignLang() out of setTemplate() and into Language->__destruct().

(Note: when a hook from a plugin is loaded, if necessary, the plugin's language file is processed and assignLang() is called.)

bhsmither commented 8 months ago

Nope.

CubeCart's execution sequence requests that templates be compiled and delivered (fetch and display) as each part of the complete page is processed. This requires LANG to be holding the language array very early in that execution sequence.

A few years ago, I did a thought experiment of what would happen and how to do it, to move all fetches and displays to the very last possible moment. Smarty would have all the variables at the ready, cached components available from previous executions, etc, etc.