CodeIgniter Forums
Get current conroller/controller-function inside a library - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: Get current conroller/controller-function inside a library (/showthread.php?tid=6752)



Get current conroller/controller-function inside a library - El Forum - 03-10-2008

[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.


Get current conroller/controller-function inside a library - El Forum - 03-10-2008

[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);



Get current conroller/controller-function inside a library - El Forum - 03-10-2008

[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');



Get current conroller/controller-function inside a library - El Forum - 03-10-2008

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


Get current conroller/controller-function inside a library - El Forum - 03-10-2008

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

Thanks for posting by the way.