Welcome Guest, Not a member yet? Register   Sign In
[Q]How to get instance of the Invoking Controller
#1

[eluser]vlad_ci[/eluser]
I plan to have a class essentially for every 'function'
in a controller

Then in the controller I will store some 'static' data that I want to share
amongst the URL handing classes.

(90% of the work on the CI side is to handle JSON requests form my AJAX client,
so I do not need to use the viewes)


One thing I cannot figure out -- is how to obtain the
a reference to the Controller that CI instanciated for a particular request

(since the function-instanciated class would not 'know' the instance it was called from)

I understand that I can pass a reference to the Controller into every class constructor,
but I would like not to do that (because it appears that the Controller instance will
be 'live' anyway for the length of the request)


Code:
class Start extends Controller
{

function hello($name)
{
  $handler=handlerFactory->get("hello");



try
{
  //how to get the instance of the 'Start' class within $handler?
  $handler->init($name);
  $handler->output();
}
catch (HandlerException $e)
{
}
catch (CIException $e)
{
}

}


thank you in advance


Messages In This Thread
[Q]How to get instance of the Invoking Controller - by El Forum - 09-03-2008, 11:31 AM
[Q]How to get instance of the Invoking Controller - by El Forum - 09-03-2008, 12:54 PM
[Q]How to get instance of the Invoking Controller - by El Forum - 09-03-2008, 03:07 PM
[Q]How to get instance of the Invoking Controller - by El Forum - 09-03-2008, 04:45 PM
[Q]How to get instance of the Invoking Controller - by El Forum - 09-03-2008, 11:06 PM
[Q]How to get instance of the Invoking Controller - by El Forum - 09-04-2008, 07:09 AM
[Q]How to get instance of the Invoking Controller - by El Forum - 09-04-2008, 08:31 AM
[Q]How to get instance of the Invoking Controller - by El Forum - 09-04-2008, 09:26 AM
[Q]How to get instance of the Invoking Controller - by El Forum - 09-04-2008, 09:54 AM



Theme © iAndrew 2016 - Forum software by © MyBB