views:

49

answers:

1

I cant load this plugin how can i load this?

I have IndexController.php and I have OthersController.php. For all those controllers, to have 1 single preDispatch method i wrote a plugin as following. Can you please guide me kindly, how i can now attach this with all other controllers???

@file: application/controllers/GlobalControllerPlugin.php

class GlobalControllerPlugin extends Zend_Controller_Plugin_Abstract 
{ 

  public function preDispatch() 
  {
     $this->view->helloworld = 
          '(from preDispatch)--->(controllers)--->(views)--->yesGreat)';

  }

}

Thanks in advance

+4  A: 

You have to add (register) the plugin to the front controller.

Either in the Bootstrap.php,

public function _initGlobalPlugin() {

    $this->bootstrap('frontController');

    // require_once 'GlobalControllerPlugin.php';
    $plugin = new GlobalControllerPlugin();

    $front = Zend_Controller_Front::getInstance();
    $front->registerPlugin($plugin);

    return $plugin;
}

or in the application.ini:

resources.frontController.plugins.global = "Global_Controller_Plugin_Common" 

Make sure, you configured autoloader properly to load namespace you use.

takeshin