Zend Framework - plugin by name not found in the registry

When I call the function in my views / helpers / file from my script inside the views / scripts / , I get this error:

Message: a plugin named 'SetBlnCompany' was not found in the registry; paths used: My_View_Helper_: / WWW / zendserver / HTDOCS / development / application / views / helpers / Zend_View_Helper_: Zend / View / Helper /: / WWW / zendserver / HTDOCS / development / application / views / helpers /

bootstrap.php

protected function _initConfig() { Zend_Registry::set('config', new Zend_Config($this->getOptions())); date_default_timezone_set('America/Chicago'); } protected function _initAutoload() { $autoloader = new Zend_Application_Module_Autoloader(array( 'namespace' => 'My', 'basePath' => dirname(__FILE__), )); return $autoloader; } 

application.ini

 resources.view.helperPath.My_View_Helper = APPLICATION_PATH "/views/helpers" 

apps / views / helpers / DropdownHelper.php

 class Zend_View_Helper_Dropdownhelper extends Zend_View_Helper_Abstract { public $blnCompany = false; public function getBlnCompany() { return $this->blnCompany; } public function setBlnCompany($blnCompany) { $this->blnCompany = $blnCompany; } } 

script causes an error

 <?php $this->setBlnCompany(true); //...etc... ?> 

EDIT to add more information to my post.

Ideally, I would use this dropdown helper class to have a get html function for the get javascript function, and many setter functions to set parameters before calling getHtml and getJavascript.

+7
source share
1 answer

Your helper should have the same name as your method. Change Zend_View_Helper_Dropdownhelper to Zend_View_Helper_GetBlnCompany and it will work. Remember to also change your file name: GetBlnCompany.php

To use the proxy method, you just need to return $this; :

 // /application/views/helpers/helpers/GetBlnCompany.php class Zend_View_Helper_GetBlnCompany extends Zend_View_Helper_Abstract { public function getBlnCompany() { return $this; } public function fooBar($blnCompany) { return ucfirst($blnCompany); } } 

Then you need to call the view helper as shown below:

 $this->getBlnCompany()->fooBar('google'); //return "Google" 
+8
source

All Articles