views:

29

answers:

1

Method __call is running when come call to undefined method. I need to trigger when calling any existing method in class, something like __callAll.

The simpliest approach would be calling the method in every method, but I don't like this approach. The uses Zend framework.

Please advise me how to do it?

+2  A: 

What you want isn't possible. The only solution I can think of is the following:

  1. Name all your functions, instead of myfunction, _myfunction.
  2. Implement a __call method that wraps each of the function calls of the class to _myfunction.
  3. Before executing the function, run your own code.

There's simply no other way to do this. I also wouldn't recommend using my way either but rather looking into some good code-design books because I bet what you want to do isn't necessary if you'd just have the right class design approach.

Robin