'Twas brillig, and Jan Pieper at 14/04/09 12:29 did gyre and gimble:
Why is it needed to create a new controller instance for each
forwarding from one action to another without changing the controller
and/or module? My init()-functionality is not able to handle multiple
calls. Okay I can change it to avoid twice execution but why is it
needed to have multiple instances of one and the same controller?

Yeah I run up against this problem too.

IMO the main dispatch loop should maintain a collection of controllers and only call "$obj = new $controllerClass" and "$obj->init()" once for each $controllerClass, then call preDispatch and action method as per normal.

At present, I have some code in my affected controllers to only run them once...

public function init()
{
  static $done = false;
  if (!$done)
  {
    // Do one time stuff
    ...
    $done = true;
  }
}


It's not so bad but like yourself, I'd prefer to have this built in.

Col

--

Colin Guthrie
gmane(at)colin.guthr.ie
http://colin.guthr.ie/

Day Job:
  Tribalogic Limited [http://www.tribalogic.net/]
Open Source:
  Mandriva Linux Contributor [http://www.mandriva.com/]
  PulseAudio Hacker [http://www.pulseaudio.org/]
  Trac Hacker [http://trac.edgewall.org/]

Reply via email to