dtgta48604 2010-07-30 17:21
浏览 21

如何配置Zend自动加载器以在默认路径之前加载资源的自定义路径

Separate but related to How to dynamically override forms and/or views using Zend?.

I want Zend to try to load custom forms/views before loading a set of default forms for a web application to let clients create custom forms for their application.

How do you configure the autoloader to load a different path before your default zend classes?

  • 写回答

1条回答 默认 最新

  • douluan5444 2010-08-02 15:20
    关注

    Like in the other question, you'll need to use a factory class. This class will check in a predefined directory the existence of the new form or otherwise the default form.

    All you will need to do is something like:

    // $formname is the parameter passed to the factory class
    $defaultclassname = "Default_Form_{$formname}";
    $classname = "New_Form_{$formname}";
    if(file_exists("/path/to/directory/of/new/{$formname}.php"))
        return new $classname();
    else
        return new $defaultclassname();
    

    This will be done in your factory class, something like /MyLib/Form/Form_Factory.php

    And then, in your controller:

    $form = MyLib_Form_Factory::createForm('user');
    
    评论

报告相同问题?

悬赏问题

  • ¥15 stm32开发clion时遇到的编译问题
  • ¥15 lna设计 源简并电感型共源放大器
  • ¥15 如何用Labview在myRIO上做LCD显示?(语言-开发语言)
  • ¥15 Vue3地图和异步函数使用
  • ¥15 C++ yoloV5改写遇到的问题
  • ¥20 win11修改中文用户名路径
  • ¥15 win2012磁盘空间不足,c盘正常,d盘无法写入
  • ¥15 用土力学知识进行土坡稳定性分析与挡土墙设计
  • ¥70 PlayWright在Java上连接CDP关联本地Chrome启动失败,貌似是Windows端口转发问题
  • ¥15 帮我写一个c++工程