• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Get current conroller/controller-function inside a library

#1
[eluser]Ebot Ndip-Agbor[/eluser]
What I want to do is get the controller and controller function that called the library i am using. Something like this
Code:
class Some_controller extends Controller  {

  function some_function()
  {
     $this->load->some_library();
  }
  
}

I want to get some_controller/some_function within the library to use for a redirect.

N.B: Didnt want to use
Code:
$this->uri->segment()
incase the controller in question is set as default controller in the routes file.
Thought of passing it as a parameter to the library :roll:. Need some insight please.

#2
[eluser]wiredesignz[/eluser]
Code:
// pass data to the library constructor
$this->load->library('a_library', 'controller_name_and_method');

// pass the object to the library constructor
$this->load->library('a_library', $this);

#3
[eluser]Ebot Ndip-Agbor[/eluser]
That does not solve my problem. I want to know the controller/controller-method that called the library. I guess the only way to achieve this will be to pass the current controller/controller-method as parameter to the library when calling it.
Code:
$this->some_library('controller_name_and_method');

#4
[eluser]wiredesignz[/eluser]
If you say so Tongue

#5
[eluser]Ebot Ndip-Agbor[/eluser]
@wiredesign

Thanks for posting by the way.


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


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