File tree Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -438,6 +438,27 @@ public function addContainer($name)
438438 }
439439
440440
441+ /********************* extension methods ****************d*g**/
442+
443+
444+ public function __call ($ name , $ args )
445+ {
446+ if ($ callback = Nette \Utils \ObjectMixin::getExtensionMethod (__CLASS__ , $ name )) {
447+ return Nette \Utils \Callback::invoke ($ callback , $ this , ...$ args );
448+ }
449+ return parent ::__call ($ name , $ args );
450+ }
451+
452+
453+ public static function extensionMethod ($ name , $ callback = NULL )
454+ {
455+ if (strpos ($ name , ':: ' ) !== FALSE ) { // back compatibility
456+ list (, $ name ) = explode (':: ' , $ name );
457+ }
458+ Nette \Utils \ObjectMixin::setExtensionMethod (__CLASS__ , $ name , $ callback );
459+ }
460+
461+
441462 /********************* interface \ArrayAccess ****************d*g**/
442463
443464
You can’t perform that action at this time.
0 commit comments