1
votes

Been pulling my hair out on why this is not working. Trying to register a controller action helper following e.g. found in Zend docs, several posts here and sundry blogs. Attempts were made both in application.ini and Bootstrap.

The helper itself resides in APPLICATION_PATH . "/controllers/helpers". The file itself is called Scoping.php. In application.ini, appnamespace = "".

<?php
class Helper_Scoping extends Zend_Controller_Action_Helper_Abstract
{
    public function direct()
    {
       // code is here
    }
 }

First I tried in the application.ini:

resources.frontController.actionhelperpaths.Helper = APPLICATION_PATH "/controllers/helpers"
resources.frontController.plugins.Scoping = "Helper_Scoping"

Calling the following in my controller throws an exception with the message: "Action Helper by name Scoping not found":

$this->_helper->Scoping();

Then I tried the following in my Bootstrap (I tried both "Helper" and "Helper_" based on other examples I saw):

protected function _initActionHelpers()
{
    Zend_Controller_Action_HelperBroker::addPath(
            APPLICATION_PATH . '/controllers/helpers', 
            'Helper_'
    );
    Zend_Controller_Action_HelperBroker::addHelper(
        new Helper_Scoping()
    );
}

This time I get an uncaught exception, but same idea: "Fatal error: Class 'Helper_Scoping' not found in /Users/ppjd/Sites/dbos/application/Bootstrap.php on line 116"

Since there are so many working examples out there, I figure it must me missing something silly. Please SOS.

2
What is the filename of your helper class? - Tim Fountain

2 Answers

0
votes

I don't try this but I think your helper class (inside your application structure: APPLICATION_PATH . "/controllers/helpers) should be 'Zend_Controller_Action_Helper_Scoping' instead 'Helper_Scoping'.

0
votes

In the event that anyone happens upon this, here is what finally worked for me: it was a namespace issue. In the Bootstrap, I made this modification ahead of the addHelper:

    $rl = $this->getResourceLoader();
    $rl->addResourceTypes(array(
        // ...other namespace settings...
        'helper' => array(
                'path'      => 'controllers/helpers',
                'namespace' => 'Helper',
        ),
    ));

Everything worked fine after that. Hope this helps someone else.

[Sometimes I feel like I spend more time trying to finesse the framework than actual application development.]