共享 Zend 模块控制器以在另一个模块中使用 [英] Share zend module controllers for use in another module

查看:26
本文介绍了共享 Zend 模块控制器以在另一个模块中使用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设我有一个 User_RegistrationController,我想像这样扩展另一个模块:

Let's say I have a User_RegistrationController from with I want to extend in another module like so:

class Clinic_RegisterController extends User_RegisterController

但我有 PHP 错误:

but I've PHP error for that:

( ! ) Fatal error: Class 'User_RegisterController' not found /application/modules/clinic/controllers/RegisterController.php on line 4

有没有办法从另一个模块扩展控制器?

Is there any way to extend a controller from another module?

推荐答案

您可以将您的基本控制器放入一个单独的库类中:

You could pull your base controller into into a separate library class:

class App_Controller_Action_MyController extends Zend_Controller_Action
{
    // your base controller code here
}

那么 foo 模块中的控制器可能为空:

Then the controller in module foo could be empty:

class Foo_MyController extends App_Controller_Action_MyController
{
}

虽然模块 bar 中的控制器可以包含您的覆盖:

while the controller in module bar could contain your overrides:

class Bar_MyController extends App_Controller_Action_MyController
{
     // override your members/methods
}

不要忘记将 App_ 添加为 autoloadernamespace.

Don't forget the add App_ as an autoloadernamespace.

这篇关于共享 Zend 模块控制器以在另一个模块中使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆