View Source

<ac:macro ac:name="unmigrated-inline-wiki-markup"><ac:plain-text-body><![CDATA[{zone-template-instance:ZFDEV:Zend Proposal Zone Template}

Intercepting Filters

[Mike Borozdin|], author
[Darby Felton|], Zend liaison

1.1 - 18 July 2006: Some thoughts of mine.

Zend Framework lacks of intercepting filters that should be executed before a specified controllers or actions in order to make some validations, for example, check whether user is authenticated if not then redirect to a login page, the code can look something like this
$controller = Zend_Controller_Front::getInstance();
$filterChain = new Zend_Filter_Chain();
$filterChain->add(new AuthenticationFilter(), "pages", array("add", "edit", "remove"));

For instance, we have PagesController that has four actions: viewAction(), addAction(), editAction(), removeAction(), the last three actions can be performed by autenticates users only, so we must check. Sure, we can put this logic to the action method or write Authenticated_Controller_Action, but what if we have to make some other validations.

Zend Framework has a plugin mechanism that is not documented now, I tried to make a plugin that extends Zend_Controller_Plugin_Abstract but it lacks of interaction with controllers and action, besides it can't stop the routing process.

If you have any ideas, please comment or e-mail me.

* [Core J2EE Patterns - Intercepting Filter|]
* [SitePoint threads|]