<?php | |
class AuthHelper extends Zend_Controller_Action_Helper_Abstract { | |
// controller action helpers can be hooked into the dispatch process which is what we need here | |
public function preDispatch() | |
{ | |
$controller = this->getActionController(); | |
if ($controller instanceof NewAuthenticable) { | |
$this->auth(); | |
} | |
} | |
private auth() | |
{ | |
//... | |
} | |
} | |
// marker interface | |
interface NewAuthenticable | |
{ | |
} | |
class MyController extends Zend_Rest_Controller implements NewAuthenticable | |
{ | |
} | |
// registering is like this | |
class Bootstrap extends Zend_Application_Bootstrap_Bootstrap | |
{ | |
protected function _initAuthHelper() | |
{ | |
Zend_Controller_Action_HelperBroker::addHelper( | |
new AuthHelper() | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment