[Solar-talk] Intercepting controllers in _setup()

Paul M Jones pmjones at solarphp.com
Sat Jun 16 16:45:57 PDT 2007


On Jun 16, 2007, at 11:46 AM, Andreas Ravnestad wrote:

> Hi,
>
> I have a rather complex per-controller authorization scheme, and to
> enforce it on controllers I am overriding _setup() and then attempt to
> use _forward() to forward to an action which is supposed to display an
> error page if the user is not authorized. However, even though the
> forwarding works fine and the error action is executed, the "original"
> action is still executed and the related view is displayed!
>
> I might be on the wrong track here, so any suggestions will be
> appreciated! :)

I'm betting you want _preRun(), which executes once before any  
actions (as opposed to _setup(), which executes only after  
construction).  See this part of the docs from Solar_Controller_Page:

* When you call [[fetch()]], these intercept methods are run in the
* following order ...
*
* 1. [[_load()]] to load class properties from the fetch() URI  
specification
*
* 2. [[_preRun()]] before the first action
*
* 3. [[_preAction()]] before each action (including _forward()-ed  
actions)
*
* 4. ... The action method itself runs here ...
*
* 5. [[_postAction()]] after each action
*
* 6. [[_postRun()]] after the last action, and before rendering
*

Hope that helps, let me know if it does not.


--

Paul M. Jones  <http://paul-m-jones.com>

Solar: Simple Object Library and Application Repository
for PHP5.  <http://solarphp.com>

Join the Solar community wiki!  <http://solarphp.org>

Savant: The simple, elegant, and powerful solution for
templates in PHP.  <http://phpsavant.com>




More information about the solar-talk mailing list