-- scabro <[email protected]> wrote
(on Friday, 27 November 2009, 01:38 PM -0800):
> Thanks very much for the instructions - I did try them, but for some reason
> they still didn't solve the problem.
>
> Here's the structure of my folders:
>
> http://n4.nabble.com/file/n802065/Picture%2B1.png
> <br />
>
> My Class name inside of the application/controllers/helpers/Initializer.php
> is : My_Action_Helper_Initializer
> and it extends Zend_Controller_Action_Helper_Abstract.
>
> Inside of the application.ini I have added the following line:
>
> resources.frontcontroller.actionhelperpaths.My_Action_Helper_Initializer =
> APPLICATION_PATH "/controllers/helpers"
>
> and in the Bootstrap.php I've created the following, protected method:
>
> protected function _initActionHelpers(){
> Zend_Controller_Action_HelperBroker::addPath(
> APPLICATION_PATH."/controllers/helpers",
> "My_Action_Helper_Initializer"
> );
> }
>
> However I'm still getting the error starting with:
>
> Fatal error: Uncaught exception 'Zend_Application_Bootstrap_Exception' with
> message 'No default controller directory registered with front controller'
> in
You didn't read my reply correctly.
First, you have specified the full class name when setting the helper
paths -- when you need to specify the class *prefix* -- everything
leading up to the helper name.
So, your helper class is "My_Action_Helper_Initializer". The class
prefix is "My_Action_Helper", and the helper name is "Initializer". You
need to use the prefix, "My_Action_Helper", in your configuration.
Second, do ONE of the approaches: EITHER use configuration OR create the
resource method in your bootstrap, NOT both.
If you do configuration, do this:
resources.frontcontroller.actionhelperpaths.My_Action_Helper =
APPLICATION_PATH "/controllers/helpers"
If you create a resource method, do this:
protected function _initActionHelpers()
{
Zend_Controller_Action_HelperBroker::addPath(
APPLICATION_PATH . "/controllers/helpers",
"My_Action_Helper"
);
}
Either one of those approaches *will* work.
Finally, a note: if this particular helper has preDispatch(),
postDispatch(), or init() hooks, you will want to actually instantiate
it and attach it to the helper broker during bootstrapping. I would do
it as follows: use the front controller configuration as described
above, and then create a resource method as follows:
protected function _initActionHelpers()
{
$this->bootstrap('FrontController');
$initializer =
Zend_Controller_Action_HelperBroker::getStaticHelper('Initializer');
}
This will ensure it's registered prior to any action controllers.
> Also - does it mean that I need to specify separately path to each Action
> Helper rather than general one for all of them?
If you follow my directions above, you can group your helpers under that
directory, and all will be available.
--
Matthew Weier O'Phinney
Project Lead | [email protected]
Zend Framework | http://framework.zend.com/