Overview
- The configuration check for headersBySAPI() is ran only once- compare the UHU4 implementation with the UHU5 implementation. Although headersBySAPI() is now wrapped in it’s own class, the same function wrapper exists in UHU5 as was present in UHU4.
- is_uuid() is still a function wrapper to uhu::is_uuid() (previously uhu4::is_uuid()), however the UHU5 version caches the result of the regex operation in static variables, so the same operation doesn’t need to be executed multiple times for the same input, providing a potential speed improvement.
- Making adjustments between the public and private versions of UHU4 was a bit of a pain. UHU4 only lists the Smarty component, but as demonstrated, components (and applications) had to be declared within uhu4::__construct(). See below for more information on how this was improved in UHU5.
- Since I never interacted with Smarty_Machine directly in UHU4, the class has been removed, with Smarty_Registry::add() now working directly with the Smarty class. From what I have learned about Composition
, the geek-fu in Smarty_Machine::display() would be better places in a class that uses Smarty_Registry::get() (see example below).
UHU Loadables
In UHU4, “loadables” weren’t really defined as such- there were just a couple of classes & class methods. In addition to the problem with components & applications being hard-coded into UHU4, there was also a rather substantial amount of duplicated logic1 2 3 4. In UHU5, this functionality is abstracted out, allowing for some polymorphic fun! 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
Although from the number of references I just gave, there now appears to be a more complex back-end for loadables the “logic” isn’t duplicated anymore, and the bulk of the references point to examples of polymorphism.
Default “loadables” are “registered” in uhu-config.php, the path to which can be overridden at runtime. This means that you can create your own uhu-config.php which registers your own loadables, without having to mess about with excluding certain files from being updated if you use SVN.
Also, by using the uhu::add_loadable() family of functions, you can choose to either register loadables in uhu-config.php, or anywhere within your code at runtime- which is useful if you want to create a sandbox for developing & testing new loadables.
Smarty Composition Example
4fbac5152d81e1_