I have a helper called Zend_View_Helper_FormVars
that's used by one of my modules.
I also have a common helper in application/common/helpers/GeneralFunctions.php
I Zend_View_Helper_FormVars
o GeneralFunctions.php
öyle bir işlevi çağırmak çalışıyorum.
İşte kısa versiyonu Zend_View_Helper_FormVars
:
class Zend_View_Helper_FormVars
{
public $reqFieldVisual='<span class="req">*</span>';
public $roles=array('admin'=>'admin', 'user'=>'user');
public $paymentMethods=array('1'=>'Check', '2'=>'Credit Card',
'3'=>'Cash', '4'=>'Other');
public function formVars(){
$this->baseUrl=Zend_Controller_Front::getInstance()->getBaseUrl();
return $this;
}
public function mkCategoryCodeSelectGroup($codeTypeArr=array(),
$codesArr=array()) {
$html='';
$html.=Zend_View_Helper_GeneralFunctions::generalFunctions()->progressMeter();
return $html;
}
}
Burada kodu GeneralFunctions.php
:
class Zend_View_Helper_GeneralFunctions
{
public function generalFunctions(){
$this->baseUrl=Zend_Controller_Front::getInstance()->getBaseUrl();
return $this;
}
public function progressMeter() {
$html='';
$html.='<span id="progressWrapper">';
$html.='<span id="progressMeter"></span>';
$html.='</span>';
$html.='';
return $html;
}
}
Ayrıca, ben GeneralFunctions
yardımcı otomatik böyle Bootstrap yüklenen ve zaten tüm modülleri mevcut bulunuyor olması söylemeyi unutmuşum:
$view->addHelperPath(APPLICATION_PATH .'/common/helpers', 'View_Helper');
İşte ne denedim, ancak bir hata alıyorum:
// application/Bootstrap.php ----------->
function _initViewHelpers() {
// add a helper for use for all modules
$view->addHelperPath(APPLICATION_PATH .'/Common/Helper', 'Common_Helper');
}
//-------------------->
// application/common/helpers/General.php ----------->
class Zend_View_Helper_General extends Zend_View_Helper_Abstract
{
public function general(){
return $this;
}
public function test(){
return 'test 123';
}
}
//-------------------->
// application/modules/dashboard/views/helpers/DashboardHelper.php ----------->
class Zend_View_Helper_DashboardHelper extends Common_Helper_General
{
public function dashboardHelper(){
return $this;
}
public function dashboardTest(){
return 'from dashboard';
}
}
//-------------------->
// application/modules/dashboard/views/scripts/index/index.phtml ----------->
echo $this->dashboardHelper()->test();
//-------------------->
Hata mesajı alıyorum:
Ölümcül hata: Sınıfı 'Common_Helper_General' on line 2 / Applications / MAMP / htdocs / mysite / uygulama / modules / pano / views / yardımcıları / DashboardHelper.php bulunamadı