• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Get controller name and method

#1
How am I able to get the controller name and method in a filter?
Reply

#2
I' am not sure if these will work in a filter or not.

get_class ($object); // Returns the name of the class of an object
get_called_class (); // The "Late Static Binding" class name
get_parent_class ($object); // Retrieves the parent class name for object or class
gettype ($var); // Get the type of a variable

is_subclass_of ($object, $class_name, $allow_string = TRUE); // Checks if the object has this class as one of its parents or implements it

get_class_methods ($class_name); // Gets the class methods' names
get_class_vars ($class_name); // Get the default properties of the class
get_object_vars ($object); // Gets the properties of the given object
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply

#3
The routing has already been done at that point since it knows what controller to run, so you can always grab the Router instance and get them from there:

Code:
$router = service('router');
$controller  = $router->controllerName();
$method = $router->methodName();
Support Development  • Practical CodeIgniter 3  • Vulcan - CLI Tools for CI4
Reply

#4
Aww, so we do have something like CI 3 had thanks Lonnie.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


Users browsing this thread:
1 Guest(s)


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2019 MyBB Group.