Here's the premise:
I have many classes where I need to perform an action BEFORE any method from any of the classes is called, my solution was to have all of the classes extend a parent class which would define a call() function which would look like:
public function call($method){
//do the something I need to do before method calls
$params = func_get_args();
//remove the $method param from the $params array
unset($params[0]);
return $this->__call($method,$params);
}
And then simply call the call method and specify the actual method I wanted to call, that way the method would get called, but inside the call method (which the class inherits from my parent class) I could carry out the action I needed to carry out before the specified method gets called.
This needs to be able to support arguments that could be arrays or strings, so anything that involves imploding an array of arguments will not work (since this would assume all arguments are strings).
I am not sure if what I have above makes sense, and I wanted to check and see if I'm going about this the wrong way or not.
Any ideas/thoughts would be greatly appreciated.
Thanks!
PS: I should note that my description of the situation above makes it sound like the reason the child classes extend the parent is simply for this purpose, in reality there are more reasons (my parent class extends Zend_Db_Table_Abstract and my database models extend the parent).