How to get controller inside component
Posted 16 November 2009 - 07:03 PM
This is how I try to access it:
I tried to recieve it onEndRequest event and also in init(). Both resolves to null.
I need to do some session-based state handling inside component which depends on the controller at hand.
Posted 17 November 2009 - 04:57 PM
Posted 17 November 2009 - 06:35 PM
onEndRequest is certainly not before controller:)
Actually why is it that so uncommon? Even if we take authorization, this also depends on controller name.
In my case I delete search query when not in specific set of pages.
Posted 17 November 2009 - 07:20 PM
Posted 19 November 2009 - 08:05 AM
The swap I believe your talking about is required in the cases where a component is used, and the controller needs to be the current controller. OnEndRequest there is no active controller so you should get null.
You probably want to override YiiApp:afterControllerAction()