views:

45

answers:

0

Hello. I'm trying to write controller plugin to check authentication. I created class of plugin, put in Application directory, Application.php and registered in Bootstrap.php. But there is an error: Fatal error: Class 'Authentication' not found. Where does Zend Framework look for plugins, how to tell it where it is?

//Application/Authentication.php
class Authentication extends Zend_Controller_Plugin_Abstract
{
    public function preDispatch(Zend_Controller_Request_Abstract $request)
    {
        $auth = Zend_Auth::getInstance();
        if ($auth->hasIdentity()) {
            return;
        }

        self::setDispatched(false);
        // handle unauthorized request...
    }
}


        //bootstrap
    protected function _initAutoloader()
    {
        $moduleLoader = new Zend_Application_Module_Autoloader(array(
        'basePath' => APPLICATION_PATH,
        'namespace' => ''));

        $autoLoader = Zend_Loader_Autoloader::getInstance();
        $autoLoader->registerNamespace('Common_');

        return $moduleLoader;              
    }



    protected function _initPlugins()
    {
        $controller = Zend_Controller_Front::getInstance();
        $controller->registerPlugin(new Authentication());
        $controller->dispatch();        
    }

Thank you.