implementation-idea for registering plugins as class-methods

From: Date: Thu, 13 Feb 2003 14:22:31 +0000
Subject: implementation-idea for registering plugins as class-methods
References: 1 2 3 4 5 6  Groups: php.smarty.general 
Request: Send a blank email to php-smarty-general+get-7727@lists.php.net to get a copy of this message
Here is an idea for the problem, that you cannot use class-methods as plugin-functions. I had a look at the Smarty source-code. To check the existance of a given functionname, you only check it with "function_exists". In my opinion you have to check it first with method_exists( $this, funcname ) if it does not exists run through the whole object-parents with get_parent_class(...) and to the same method_exists-call with the parents until you either found a method with the given name or until there are no more parents. Then at last search with "function_exists" Of course you have to store somewhere the exact object to the function, so that you are able to call it. As an addition you could expand the syntax of register-functions and allow an additional parameter which directly tells you in which class to look for the function (in that case you first have to search for that class in your object-parents) And another parameter with which you can transport an object instead of using "$this"... Would this be hard to implement? It would solve all the problem and would also be a great step forward! What do you think? with regards, Matthias

« previous php.smarty.general (#7727) next »