At the moment, any code that needs to be called when the theme is initialised has a register() method, and we have to manually add a call to ->register() in the Registrar class.
Upon class instantiation, could we pass an object as the first argument to the constructor, then if the class needs to register anything it calls $object->callMyRegisterMethodLater($this);. Then after all the classes have been instantiated, simply call $object->callAllTheRegisterMethods();.
This would add at least one extra class (or we could just pass the registrar class - that would make sense), but it would mean we would only need to make sure the class gets instantiated and we wouldn't have to worry about calling a hundred 'register()methods in theRegistrar` class.
At the moment, any code that needs to be called when the theme is initialised has a
register()
method, and we have to manually add a call to->register()
in theRegistrar
class.Upon class instantiation, could we pass an object as the first argument to the constructor, then if the class needs to register anything it calls
$object->callMyRegisterMethodLater($this);
. Then after all the classes have been instantiated, simply call$object->callAllTheRegisterMethods();
.This would add at least one extra class (or we could just pass the registrar class - that would make sense), but it would mean we would only need to make sure the class gets instantiated and we wouldn't have to worry about calling a hundred 'register()
methods in the
Registrar` class.