duanbichou4942 2017-05-23 14:37
浏览 28

如何使ZF模块扩展默认模块功能?

I have an "ancient" ZF1 application, which has lot of controllers in the default module. It has also lot of modules. The modules have sometimes own logic inside (logically), but in most of the cases they just add new controllers (module specific), but must also handle the common application functionality.

To be more specific, here is a sample application structure:

<pre>
application
  controllers
    AController.php
    BController.php
    CController.php
  modules
    m1
      controllers
        M1aController.php
        M1bController.php
    m2
      controllers
        M2aController.php
        M2bController.php

etc.
</pre>

What I want to achieve is, that if an request to a module comes, asking for a controller from the default module, then this controller to be called.

Example (having in mind the above schema):

http://www.example.com/a/b - executes the action B from AController.php (standart ZF behavior)

http://www.example.com/m1/m1a/b - executes the action B from M1aController.php in module m1 (also standart ZF behavious)

http://www.example.com/m1/a/b - it must execute the action B from AController.php in the default module, regardless of the specified m1 module

So if the called controller is missing in the module, then the controller from the default module must be called.

Furthermore I need a possibility to have different view scripts in the modules for the controllers/actions from the default module.

Extending the sample from above:

<pre>
application
  controllers
    ...
  views
    scripts
      a
        b.phtml
        c.phtml
...
  modules
    m1
      views
        scripts
          a
            b.phtml
            c.phtml
etc.
</pre>

In this case when http://www.example.com/m1/a/b is called, it must execute the action B from AController.php, but using the b.phtml view script from the module directory, not from the default one.

How can I achieve such functionality?

Thanks in advance!

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥100 支付宝批量检测实名工具
    • ¥15 基于单片机的靶位控制系统
    • ¥15 AT89C51控制8位八段数码管显示时钟。
    • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
    • ¥15 下图接收小电路,谁知道原理
    • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
    • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
    • ¥15 手机接入宽带网线,如何释放宽带全部速度
    • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测
    • ¥15 ETLCloud 处理json多层级问题