Welcome Guest, Not a member yet? Register   Sign In
Get name of parent method and classf
#1

Hello, i'm writing a log script which basicaly logs the user actions and stores them in the database for further analysis. Its a very basic script but it does the job. However i need a way to get the name of the parent methon which the log action is called and the class. The standard php get_parent_class returns CI_Controller instead on the class name i want.




For example if i have something like this:




PHP Code:
class MyClass extends CI_Controller {

public function 
MyFunction() {
 
  $this->log->log_actions($data);
}


 i want a way to the the MyClass name and the MyFunction.
Reply
#2

You sholdn't use get_called_class ?

or you can declare you MY_Controller class in application/core with some fields like $class_name , ... and user it as parent of your controllers instead of CI_controller, so you can initialize that fields in __construct function for each subClass.
ressan.ir
CI is nice Heart
Reply
#3

__CLASS__ doesn't work also ???
NexoPOS 2.6.2 available on CodeCanyon.
Reply
#4

What about segment(2) for the class name and segment(3) for the method name?
Reply
#5

(This post was last modified: 06-13-2015, 01:09 PM by Blair2004.)

(06-13-2015, 09:03 AM)Wouter60 Wrote: What about segment(2) for the class name and segment(3) for the method name?

That nice idea, but no so if custom route is enabled or routes are remapped.
NexoPOS 2.6.2 available on CodeCanyon.
Reply
#6

Pretty much everything you suggested works. I will probably go with the segments Smile
Reply




Theme © iAndrew 2016 - Forum software by © MyBB