久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

Zend框架如何在不同模塊中使用相同的模型?

How to Use Same Models in Different Modules in Zend Framework?(Zend框架如何在不同模塊中使用相同的模型?)
本文介紹了Zend框架如何在不同模塊中使用相同的模型?的處理方法,對(duì)大家解決問(wèn)題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)吧!

問(wèn)題描述

我正在一個(gè)現(xiàn)有項(xiàng)目中實(shí)施 Zend Framework,該項(xiàng)目有一個(gè)公共營(yíng)銷(xiāo)區(qū)、一個(gè)私有成員區(qū)、一個(gè)管理站點(diǎn)和一個(gè)營(yíng)銷(xiāo)活動(dòng)管理站點(diǎn).目前,營(yíng)銷(xiāo)區(qū)域和成員區(qū)域的控制器腳本都在網(wǎng)站的根目錄下,然后是單獨(dú)的 admin 文件夾和營(yíng)銷(xiāo)活動(dòng)網(wǎng)站的另一個(gè)文件夾.

I am working on implementing Zend Framework within an existing project that has a public marketing area, a private members area, an administration site, and a marketing campaign management site. Currently these are poorly organized with the controller scripts for the marketing area and the members area all being under the root of the site and then a separate folder for admin and another folder for the marketing campaign site.

在實(shí)施 Zend 框架時(shí),我希望能夠?qū)⒖刂破骱鸵晥D拆分為模塊(一個(gè)用于成員區(qū)域,一個(gè)用于公共營(yíng)銷(xiāo)區(qū)域,一個(gè)用于管理站點(diǎn),一個(gè)用于營(yíng)銷(xiāo)活動(dòng)管理站點(diǎn)),但我需要能夠?qū)⒚總€(gè)模塊指向同一個(gè)模型,因?yàn)樗腥齻€(gè)組件都在同一個(gè)數(shù)據(jù)庫(kù)和同一個(gè)業(yè)務(wù)對(duì)象上工作.

In implementing the Zend Framework, I would like to create be able to split the controllers and views into modules (one for the members area, one for the public marketing area, one for the admin site, and one for the marketing campaign admin site) but I need to be able to point each module to the same model's since all three components work on the same database and on the same business objects.

但是,我無(wú)法在文檔中找到有關(guān)如何執(zhí)行此操作的任何信息.任何人都可以提供有關(guān)如何執(zhí)行此操作的鏈接或有關(guān)如何完成此操作的一些簡(jiǎn)單說(shuō)明的幫助嗎?

However, I haven't been able to find any information on how to do this in the documentation. Can anyone help with either a link on how to do this or some simple instructions on how to accomplish it?

推薦答案

我所做的是將通用類(lèi)保存在模塊層次結(jié)構(gòu)之外的庫(kù)"目錄中.然后設(shè)置我的 INCLUDE_PATH 使用相應(yīng)模塊的models"目錄,加上公共的library"目錄.

What I do is keep common classes in a "library" directory outside of the modules hierarchy. Then set my INCLUDE_PATH to use the "models" directory of the respective module, plus the common "library" directory.

docroot/
    index.php
application/
    library/    <-- common classes go here
    default/
        controllers/
        models/
        views/
    members/
        controllers/
        models/
        views/
    admin/
        controllers/
        models/
        views/
. . .

在我的引導(dǎo)腳本中,我將application/library/"添加到INCLUDE_PATH.然后在每個(gè)控制器的 init() 函數(shù)中,我將該模塊的models/"目錄添加到 INCLUDE_PATH.

In my bootstrap script, I'd add "application/library/" to the INCLUDE_PATH. Then in each controller's init() function, I'd add that module's "models/" directory to the INCLUDE_PATH.

edit:setControllerDirectory()setModuleDirectory() 等函數(shù)不會(huì)將各自的模型目錄添加到 INCLUDE_PATH.無(wú)論如何,您必須自己執(zhí)行此操作.以下是如何操作的一個(gè)示例:

edit: Functions like setControllerDirectory() and setModuleDirectory() don't add the respective models directories to the INCLUDE_PATH. You have to do this yourself in any case. Here's one example of how to do it:

$app = APPLICATION_HOME; // you should define this in your bootstrap
$d = DIRECTORY_SEPARATOR;
$module = $this->_request->getModuleName(); // available after routing
set_include_path(
  join(PATH_SEPARATOR,
    array(
      "$app{$d}library",
      "$app{$d}$module{$d}models",
      get_include_path()
    )
  )
);

您可以在引導(dǎo)程序中將library"添加到您的路徑中,但是您不能在引導(dǎo)程序中為正確的模塊添加models"目錄,因?yàn)槟K依賴(lài)于路由.有些人在他們的控制器的 init() 方法中這樣做,有些人為 ActionController 的 preDispatch 鉤子編寫(xiě)了一個(gè)插件來(lái)設(shè)置 INCLUDE_PATH.

You could add the "library" to your path in the bootstrap, but you can't add the "models" directory for the correct module in the bootstrap, because the module depends on routing. Some people do this in the init() method of their controllers, and some people write a plugin for the ActionController's preDispatch hook to set the INCLUDE_PATH.

這篇關(guān)于Zend框架如何在不同模塊中使用相同的模型?的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

【網(wǎng)站聲明】本站部分內(nèi)容來(lái)源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問(wèn)題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請(qǐng)聯(lián)系我們刪除處理,感謝您的支持!

相關(guān)文檔推薦

Action View Helper in Zend - Work around?(Zend 中的動(dòng)作視圖助手 - 解決方法?)
Is this a good way to match URI to class/method in PHP for MVC(這是將 URI 與 PHP 中用于 MVC 的類(lèi)/方法匹配的好方法嗎)
Where do I save partial (views) in Zend Framework, to be accessible for all Views in my App?(我在哪里保存 Zend Framework 中的部分(視圖),以便我的應(yīng)用程序中的所有視圖都可以訪(fǎng)問(wèn)?) - IT屋-程序員軟件開(kāi)發(fā)技術(shù)
Having a single entry point to a website. Bad? Good? Non-issue?(有一個(gè)網(wǎng)站的單一入口點(diǎn).壞的?好的?沒(méi)問(wèn)題?)
Is MVC + Service Layer common in zend or PHP?(MVC + 服務(wù)層在 Zend 或 PHP 中常見(jiàn)嗎?)
Hello World example in MVC approach to PHP(PHP MVC 方法中的 Hello World 示例)
主站蜘蛛池模板: 福利视频亚洲 | 亚洲欧美一区二区三区在线 | 国产男女精品 | 久久精品国产一区二区电影 | 国产一区二区三区视频 | 免费观看视频www | 91精品中文字幕一区二区三区 | 免费在线观看91 | 综合久久综合久久 | 国产精品福利视频 | 日韩一区二区久久 | 国产亚洲成av人片在线观看桃 | 亚洲精品成人av久久 | 欧美日韩久久 | 午夜视频网站 | 亚洲乱码一区二区 | 日韩精品一区二区三区视频播放 | 日韩成人在线观看 | 欧美综合国产精品久久丁香 | 亚洲欧美日韩精品久久亚洲区 | 久久精品国产99国产精品 | 人人做人人澡人人爽欧美 | 亚洲最大看片网站 | 久久国产亚洲 | 成人啊啊啊| 黄网站在线播放 | 国产色片 | 亚洲国产精品久久久久婷婷老年 | 韩日一区 | 亚洲午夜视频在线观看 | 午夜精品一区二区三区在线视频 | 成人精品国产一区二区4080 | 久久aⅴ乱码一区二区三区 亚洲国产成人精品久久久国产成人一区 | 美女国内精品自产拍在线播放 | 99久久夜色精品国产亚洲96 | 国产成人精品综合 | 中文字幕免费 | 欧美成人精品一区二区三区 | 99视频在线播放 | 91在线视频免费观看 | 91视频在线观看 |