question about resources.frontController.actionHelperPaths in application.ini

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

question about resources.frontController.actionHelperPaths in application.ini

calbear77
Hi Everyone,
I have a question about the specific functionality of this line in application.ini:

resources.frontController.actionHelperPaths.MyStuff_Controller_Action_Helper = APPLICATION_PATH "/../library/MyStuff/Controller/Action/Helper"

I have two action helpers that I am trying to employ, one for ACL check on preDispatch and one in order to use a variant of Matthew's dependency injector, which he artfully describes here:
http://weierophinney.net/matthew/archives/235-A-Simple-Resource-Injector-for-ZF-Action-Controllers.html

If anyone is curious, I'm using that dependency injector to give my controllers access to a Doctrine 2.0 entity manager, but I digress.

The question I have is that I'm trying to set up application.ini so that it runs my two action helpers automatically without specifically calling them in my bootstrap, but that doesn't seem to be happening when I add the line above.

Instead, I am currently saddled with adding the following method in my Bootstrap class:

    protected function _initActionHelpers()
    {
    // resource injector
        Zend_Controller_Action_HelperBroker::addHelper(
            new MyStuff_Controller_Action_Helper_ResourceInjector()
        );
        // acl
        Zend_Controller_Action_HelperBroker::addHelper(
            new MyStuff_Controller_Action_Helper_Acl()
        );
    }

I would prefer that this be handled in the config, if possible, but I don't seem to have enough info to guarantee that this is happening.

Thanks for any help you can offer!

Kevin
Reply | Threaded
Open this post in threaded view
|

Re: question about resources.frontController.actionHelperPaths in application.ini

weierophinney
Administrator
-- calbear77 <[hidden email]> wrote
(on Monday, 10 January 2011, 09:42 PM -0800):
> Hi Everyone,
> I have a question about the specific functionality of this line in
> application.ini:
>
> resources.frontController.actionHelperPaths.MyStuff_Controller_Action_Helper
> = APPLICATION_PATH "/../library/MyStuff/Controller/Action/Helper"

<snip>

> The question I have is that I'm trying to set up application.ini so that it
> runs my two action helpers automatically without specifically calling them
> in my bootstrap, but that doesn't seem to be happening when I add the line
> above.

Correct. Currently, there's no functionality for auto-adding helpers
within the FrontController resource -- just prefix/path pairs. As such,
you're stuck with either the method you use below, or creating a
re-usable resource that can be configured to instantiate and attach
specified helpers to the action helper broker.

This latter would be fairly trivial to accomplish -- use configuration
like the following:

  resources.actionhelpers[] = "ResourceInjector"
  resources.actionhelpers[] = "Acl"

and then have the init() method of that resource do something like this:

  $this->getBootstrap()->bootstrap('frontcontroller');
  foreach ($this->getOptions() as $helper) {
      Zend_Controller_Action_HelperBroker::getStaticHelper($helper);
  }

Make sense?

> Instead, I am currently saddled with adding the following method in my
> Bootstrap class:
>
>     protected function _initActionHelpers()
>     {
>     // resource injector
>         Zend_Controller_Action_HelperBroker::addHelper(
>             new MyStuff_Controller_Action_Helper_ResourceInjector()
>         );
>         // acl
>         Zend_Controller_Action_HelperBroker::addHelper(
>             new MyStuff_Controller_Action_Helper_Acl()
>         );
>     }
>
> I would prefer that this be handled in the config, if possible, but I don't
> seem to have enough info to guarantee that this is happening.
>
> Thanks for any help you can offer!

--
Matthew Weier O'Phinney
Project Lead            | [hidden email]
Zend Framework          | http://framework.zend.com/
PGP key: http://framework.zend.com/zf-matthew-pgp-key.asc
Reply | Threaded
Open this post in threaded view
|

Re: question about resources.frontController.actionHelperPaths in application.ini

calbear77
Yep!  Thanks Matthew!