Skip to content

Instantly share code, notes, and snippets.

@acid24 acid24/auth
Last active Jun 24, 2018

Embed
What would you like to do?
<?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
You can’t perform that action at this time.