Re: [SMARTY] implementation-idea for registering plugins as class-methods

From: Date: Thu, 13 Feb 2003 14:44:25 +0000
Subject: Re: [SMARTY] implementation-idea for registering plugins as class-methods
References: 1 2 3 4 5 6 7  Groups: php.smarty.general 
Request: Send a blank email to php-smarty-general+get-7730@lists.php.net to get a copy of this message
On Thu, Feb 13, 2003 at 03:22:31PM +0100, Matthias Mohr wrote: > 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. this is unnecessary. a subclass inherits all methods of it's parent-class. so a parent-class cannot have a method, that is unknown to it's children. > 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! i think it would be hard. why do you want to put everything inside a subclass of class Smarty anyway ?? with the lack of protected variables and with php's limited oop-capabilities things can get very complicated und nearly undebuggable with deep class-hierarchies and all-in-one objects that provide functionality for everything. smarty knows register_object() since 2.4.0 and method-calls to those objects. i would try using these first. > What do you think? > > with regards, > Matthias

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