Ferreteria/v0.5/@cls/tExecutableTwig/DoLocalMethod(): Difference between revisions
(Created page with "{{fmt/title|<code>ferret\{{l/ver/class|layout}}\tExecutableTwig->DoLocalMethod()</code>}} ==About== This method determines what local method to call for the receive...") |
No edit summary |
||
Line 1: | Line 1: | ||
{{fmt/title|<code>[[../|ferret]]\{{l/ver/class|layout}}\tExecutableTwig->DoLocalMethod()</code>}} | {{fmt/title|<code>[[../|ferret]]\{{l/ver/class|layout}}\tExecutableTwig->DoLocalMethod()</code>}} | ||
==About== | ==About== | ||
This method determines what local method to call for the received event-type. Podling classes can override it to add support for additional event-types. | This method determines what local method to call for the received event-type by checking the {{l/ver/class/method|caEvent|Code}} against known types. Podling classes can override it to add support for additional event-types. ({{l/ver/class|tRenderableTwig}} does this for {{l/same|OnRender()}}.) | ||
==Changes== | ==Changes== | ||
===2022-11-29=== | ===2022-11-29=== |
Latest revision as of 18:36, 29 November 2022
About
This method determines what local method to call for the received event-type by checking the Code against known types. Podling classes can override it to add support for additional event-types. (tRenderableTwig does this for OnRender().)
Changes
2022-11-29
This method was originally created to handle the automatic dispatch of events by calling whatever method was specified by caEvent::Method. Although this methodology is kind of clever, and reduces a bit of code complexity, I'm discovering that it leads to coding confusion because of making it more difficult to figure out where the event-methods are called and initially defined. (It also may pose an obstacle for porting Ferreteria to other languages, especially those that are compiled rather than interpreted.)
I'm now converting this to just dispatch via explicit switch/case
, and allowing podling classes to override it (removing final
) to add support for additional event-types.
Method code was:
final protected function DoLocalMethod(caEvent $oe) : void {
$sMeth = $oe->Method();
// +DEBUG
#$oc = new F\cClassWrapper($this);
#$sc = get_called_class();
#$om = $oc->GetMethod($sMeth);
#$ftMeth = $om->RenderFunc();
#echo " > DISPATCH <b>[$sc::$ftMeth]</b><br>";
// -DEBUG
$this->$sMeth($oe);
$oe->DoCallback($this); // do any requested callback
// +DEBUG
#echo " < [$sc::$sMeth]<br>";
// -DEBUG
}