添加操作助手類後,出現致命錯誤。我正在嘗試加載對應於調用佈局的佈局。以下是我的代碼片段:Zend框架控制器操作助手
class Zend_Controller_Action_Helper_Layout extends Zend_Controller_Action_Helper_Abstract {
public $pluginLoader;
public function __construct()
{
// TODO Auto-generated Constructor
$this->pluginLoader = new Zend_Loader_PluginLoader();
}
public function preDispatch()
{
$bootstrap = $this->getActionController()->getInvokeArg('bootstrap');
$config = $bootstrap->getOptions();
$module = $this->getRequest()->getModuleName();
if (isset($config[$module]['resources']['layout']['layout'])) {
$layoutScript = $config[$module]['resources']['layout']['layout'];
$this->getActionController()->getHelper('layout')->setLayout($layoutScript);
}
}
}
然後我說在bootstrap.php中裝載機:
protected function _initLayoutHelper() {
$this->bootstrap('frontController');
Zend_Controller_Action_HelperBroker::addPath(APPLICATION_PATH .'/controllers/helpers');
$layout = Zend_Controller_Action_HelperBroker::addHelper(new Zend_Controller_Action_Helper_Layout());
}
所有加入我正在申請/控制器/傭工一個輔助類的第一
以下是我的application.ini:
[production]
autoloaderNamespaces.tree = "Tree_"
phpSettings.display_startup_errors = 0
phpSettings.display_errors = 0
includePaths.library = APPLICATION_PATH "/../library"
bootstrap.path = APPLICATION_PATH "/Bootstrap.php"
bootstrap.class = "Bootstrap"
resources.frontController.controllerDirectory = APPLICATION_PATH "/controllers"
resources.frontController.moduleDirectory = APPLICATION_PATH "/modules"
resources.frontController.helperDirectory = APPLICATION_PATH "/controllers/helpers"
resources.modules[] = ""
contact.resources.frontController.defaultControllerName = "index"
resources.layout.layoutPath = APPLICATION_PATH "/layouts/scripts"
resources.layout.layout = layout
admin.resources.layout.layout = admin
#admin.resources.layout.layoutPath = APPLICATION_PATH "/layouts/scripts"
resources.view[] =
[staging : production]
[testing : production]
phpSettings.display_startup_errors = 1
phpSettings.display_errors = 1
[development : production]
phpSettings.display_startup_errors = 1
phpSettings.display_errors = 1
當運行此代碼我收到以下錯誤:
Warning: include(Zend\Controller\Action\Helper\LayoutLoader.php) [function.include]: failed to open stream: No such file or directory in D:\personal\proj\renovate\library\Zend\Loader.php on line 83
Warning: include() [function.include]: Failed opening 'Zend\Controller\Action\Helper\LayoutLoader.php' for inclusion (include_path='D:\personal\proj\renovate\application/../library;D:\personal\proj\renovate\library;.;C:\php5\pear') in D:\personal\proj\renovate\library\Zend\Loader.php on line 83
Fatal error: Class 'Zend_Controller_Action_Helper_LayoutLoader' not found in D:\personal\proj\renovate\application\Bootstrap.php on line 33
請讓我知道,我怎麼可以從這個問題出來了。我是Zend Framework的初學者。