Php 未加载separte模块中的操作\u帮助程序
我阅读了这篇很棒的文章,但目前我无法完成我的简化示例 问题预剥离未加载 我创建了新模块user(还有controllerUserController,我希望这不会影响加载) 我在用户中添加了两个文件 Bootstrap.php-在模块用户下Php 未加载separte模块中的操作\u帮助程序,php,zend-framework,zend-framework-modules,Php,Zend Framework,Zend Framework Modules,我阅读了这篇很棒的文章,但目前我无法完成我的简化示例 问题预剥离未加载 我创建了新模块user(还有controllerUserController,我希望这不会影响加载) 我在用户中添加了两个文件 Bootstrap.php-在模块用户下 class User_Bootstrap extends Zend_Application_Module_Bootstrap { public function initResourceLoader() { $loader = $this->
class User_Bootstrap extends Zend_Application_Module_Bootstrap {
public function initResourceLoader() {
$loader = $this->getResourceLoader();
$loader->addResourceType('helper', 'helpers', 'Helper');
}
protected function _initHelpers() {
Zend_Controller_Action_HelperBroker::addHelper(
new User_Helper_HandleLogin()
);
}
/user/helpers和类HandleLogin下的新文件夹
class User_Helper_HandleLogin extends Zend_Controller_Action_Helper_Abstract {
protected $view;
public function preDispatch() {
echo 'called';
if (($controller = $this->getActionController()) === null) {
return;
}
$this->createProfileWidget();
}
public function createProfileWidget() {
if (!$view = $this->getView()) {
return;
}
$view->user = '<h2>HELLO WORLD</h2>';
}
public function createLoginForm() {
}
public function getView() {
if ($this->view !== null) {
return $this->view;
}
$controller = $this->getActionController();
$view = $controller->view;
if (!$view instanceof Zend_View_Abstract) {
return;
}
//$view->addScriptPath(dirname(__FILE__) .'/../views/scripts');
$this->view = $view;
return $view;
}
class User\u Helper\u HandleLogin扩展了Zend\u Controller\u Action\u Helper\u抽象{
受保护的$view;
公共职能预分配(){
回声“召唤”;
if(($controller=$this->getActionController())==null){
返回;
}
$this->createProfileWidget();
}
公共函数createProfileWidget(){
如果(!$view=$this->getView()){
返回;
}
$view->user='HELLO WORLD';
}
公共函数createLoginForm(){
}
公共函数getView(){
如果($this->view!==null){
返回$this->view;
}
$controller=$this->getActionController();
$view=$controller->view;
if(!$view instanceof Zend\u view\u Abstract){
返回;
}
//$view->addScriptPath(目录名(_文件)'/../views/scripts');
$this->view=$view;
返回$view;
}
}
最后将输出添加到layout.phtml中
<?php echo $this->user ?>
用户助手手动登录的
init()功能是否有效?User\u引导是否有效?:)也许您忘记了config.ini中的resources.modules[]=
?我添加了handleLogin(),但仍然存在查找和加载插件的问题。handleLogin插件在用户模块引导程序中注册,所以应该自动加载吗?我不能单独发布错误是致命错误:注册表中找不到未捕获的异常“Zend_Loader_PluginLoader_exception”,消息为“Plugin by name”“HandleLogin”;使用的路径:ZendX\u JQuery\u View\u Helper\ux:ZendX/JQuery/View/Helper/Zend\u View\u Helper\ux:Zend/View/Helper/:/var/www/review/application/views/helpers//in/home/risto/library/Zend/Loader/PluginLoader.php:412堆栈跟踪:#0谢谢你,添加了resources.modules[]行,现在可以工作了,我找到的唯一解释来自akrabat.com网站“resources.modules告诉Zend_应用程序加载modules资源,然后查找模块引导类。”这正是我需要的。User_Helper_HandleLogin的函数是否有效?User_bootstrap是否有效?:)也许您忘记了config.ini中的resources.modules[]=
?