Welcome, Guest. Register Now!
   
Mark Forums Read Mark Forums Read Mark Forums Read


Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 02-05-2008, 04:14 PM
greboguru's Avatar
Junior Member
 
Join Date: Feb 2008
Location: UK
Posts: 16
Default Implementing Zend_Controller_Action_Helper_Abstract

Hi,

I'm very new to this framework .... I'm trying to add a controller action helper but all I get is the following exception

Code:
// The Action Helper Class require_once 
'Zend/Controller/Action/Helper/Abstract.php'; class Application_Controllers_Helpers_SideBar extends
 Zend_Controller_Action_Helper_Abstract { public function postDispatch() { 
echo "hello"; } }exception 'Zend_Controller_Action_Exception' with message 'Action Helper by name SideBar not found.' in 
C:\xampp\xampplite\htdocs\zf-tut\library\Zend\Controller\Action\HelperBroker.php:341
in my bootstrap I've added the prefix to the helper thus

Code:
...
// add helper prefix
Zend_Controller_Action_HelperBroker::addPrefix('application_controllers_helpers');
...

my helper class is located in application/controllers/helpers and is called SideBar.php. I've implemented the code as follows

Code:
// The Action Helper Class
require_once 'Zend/Controller/Action/Helper/Abstract.php';

class Application_Controllers_Helpers_SideBar extends Zend_Controller_Action_Helper_Abstract
{
   public function postDispatch() 
   {
      echo "hello";
   }
}
and in my helper I'm trying to access it by

Code:
if (Zend_Controller_Action_HelperBroker::getStaticHelper('SideBar'))
{
    echo 'SideBar helper registered';
}
else
{
    echo 'SideBar helper not registered';
}

and this is throwing the exception.


Any help would be appreciated.

Thanks!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 02-06-2008, 09:43 AM
greboguru's Avatar
Junior Member
 
Join Date: Feb 2008
Location: UK
Posts: 16
Wink

OK, sorted the problem

The helper class needs a prefix ending in '_'.

My helper class is now defined as

Code:
require_once 'Zend/Controller/Action/Helper/Abstract.php';

class My_SideBar extends Zend_Controller_Action_Helper_Abstract
{
.......
}
and this lives in application/controllers/helpers.

I register it with the the broker thus

Code:
Zend_Controller_Action_HelperBroker::addPath('application/controllers/helpers', 'My_');
and I can now reference it ...

Code:
Zend_Controller_Action_HelperBroker::getStaticHelper('SideBar');
If you search for 'Zend_Controller_Action_Helper_Abstract' you'll find a few documeted examples of this problem.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT. The time now is 09:55 PM.