naming and path of controller plugins

41 views Asked by At

I'm confused, I've read everything I found about the topic, but it doesn't work.

I want to build a plugin to use the preDispatch Action.

I would like to name it like this:

class Mosaik_Controller_Plugin_Acl extends Zend_Controller_Plugin_Abstract

My path and name of the file: C:\wamp\www\mosaik\application\controllers\plugins\Acl.php

I tried to register the class in my application.ini:

resources.frontController.plugins.acl = "Mosaik_Controller_Plugin_Acl"

I get some errors:

Fatal error: Class 'Mosaik_Controller_Plugin_Acl' not found in C:\wamp\www\mosaik\library\Zend\Application\Resource\Frontcontroller.php on line 117

My exact question is: For this example, how should be the registering in my application.ini. Is the name of my plugin class correct or do I have to change it? (Like?) I know it is a basic understanding problem, but nothing helped.

1

There are 1 answers

1
Adrian World On BEST ANSWER

Your confusion is mainly because of autoloading and naming/namespaces. The name of your plugin doesn't match an existing namespace (at least not for a standard ZF setup) and autoloading will not be able to match this against an file. Hence your Class cannot be found.

In a standard ZF1 since at least Version 1.9 -> see 30.3.2 the Module Resource Autoloader we have resource type mapping for plugins and you can create an application/plugins folder and add your plugins. Here's what it would look like for you

C:\wamp\www\mosaik\application\plugins\Acl.php

// the new class name
class Application_Plugin_Acl extends Zend_Controller_Plugin_Abstract

// the new application.ini
resources.frontController.plugins.acl = "Application_Plugin_Acl"