• <small id='7NgiA'></small><noframes id='7NgiA'>

  • <tfoot id='7NgiA'></tfoot>
    <i id='7NgiA'><tr id='7NgiA'><dt id='7NgiA'><q id='7NgiA'><span id='7NgiA'><b id='7NgiA'><form id='7NgiA'><ins id='7NgiA'></ins><ul id='7NgiA'></ul><sub id='7NgiA'></sub></form><legend id='7NgiA'></legend><bdo id='7NgiA'><pre id='7NgiA'><center id='7NgiA'></center></pre></bdo></b><th id='7NgiA'></th></span></q></dt></tr></i><div id='7NgiA'><tfoot id='7NgiA'></tfoot><dl id='7NgiA'><fieldset id='7NgiA'></fieldset></dl></div>
  • <legend id='7NgiA'><style id='7NgiA'><dir id='7NgiA'><q id='7NgiA'></q></dir></style></legend>

      <bdo id='7NgiA'></bdo><ul id='7NgiA'></ul>

        如何使用 Zend Framework 正确创建域?

        时间:2023-10-03

        <i id='UkYpH'><tr id='UkYpH'><dt id='UkYpH'><q id='UkYpH'><span id='UkYpH'><b id='UkYpH'><form id='UkYpH'><ins id='UkYpH'></ins><ul id='UkYpH'></ul><sub id='UkYpH'></sub></form><legend id='UkYpH'></legend><bdo id='UkYpH'><pre id='UkYpH'><center id='UkYpH'></center></pre></bdo></b><th id='UkYpH'></th></span></q></dt></tr></i><div id='UkYpH'><tfoot id='UkYpH'></tfoot><dl id='UkYpH'><fieldset id='UkYpH'></fieldset></dl></div>

            • <bdo id='UkYpH'></bdo><ul id='UkYpH'></ul>

                1. <legend id='UkYpH'><style id='UkYpH'><dir id='UkYpH'><q id='UkYpH'></q></dir></style></legend>

                  <small id='UkYpH'></small><noframes id='UkYpH'>

                  <tfoot id='UkYpH'></tfoot>
                    <tbody id='UkYpH'></tbody>
                  本文介绍了如何使用 Zend Framework 正确创建域?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  我不久前问了这个问题但现在我希望在我的数据库访问层和域层之间实现实际分离.我还将努力将业务逻辑移入它所属的域中并移出控制器脚本.

                  I asked this question a while back but now I'm looking to implement an actual separation between my database access layer and the domain layer. I am also going to be working to move business logic into the domain where it belongs and out of the controller scripts.

                  我正在使用 Zend Framework,它为数据访问层实现了表数据网关和行数据网关模式,但它显然没有真正定义如何构建与数据访问层分离的域层.我考虑过使用 Active Record 模式,其中域逻辑与数据访问逻辑共存,但我认为 Active Record 至少会处理以下情况:

                  I'm using Zend Framework which implements the Table Data Gateway and Row Data Gateway patterns for the data access layer, but it apparently fails to really define how to build a domain layer that is separate from the data access layer. I've considered using an Active Record pattern where the domain logic coexists with the data access logic, but I have the following situation that occurs at least once that I don't think Active Record will handle:

                  我有一个包含 person_id 和 userType 字段的Person"表.

                  I have a single table "Person" which contains person_id and userType fields.

                  每个用户类型(管理员、采购员、助理、主管)都有与之关联的特定业务逻辑,并且所有类型都从 Person 对象继承了一些基本功能.

                  Each userType (admin, buyer, associate, supervisor) has specific business logic associated with it and all types inherit some basic functionality from a Person object.

                  我不想使用专门属于一种类型用户的业务逻辑来膨胀行数据网关对象,但我不确定如何构建域层来表示不同类型的用户.例如,我是创建一个包含 PersonGateway 对象的 Person 对象,然后编写将调用传递给网关对象的包装函数,还是编写 Person 对象来扩展 PersonGateway 对象,然后仅实现我需要的特定功能?

                  I don't want to bloat the Row Data Gateway object with business logic that belongs specifically to just one type of user but I'm not certain how to construct the domain layer to represent the different types of users. For example, do I make a Person object that contains the PersonGateway object and then write wrapper functions that pass calls to the gateway object, or do I write the Person object to extend the PersonGateway object and then only implement the specific functions that I need?

                  同样,我通常认为这是(部分)一个工厂问题,我需要一个工厂方法来实例化基于 userType 的正确子类.这仍然是 Zend Framework 的 Zend_Db 类的最佳方法吗?

                  Likewise, I would typically think that this is (in part) a factory problem where I need a factory method that will instantiate the correct sub-class based on userType. Is that still the best method here with Zend Framework's Zend_Db class?

                  任何关于如何在 Zend_Db 之上正确创建域模型的教程的建议或链接将不胜感激.

                  Any suggestions or links to tutorials that talk about how to properly create a domain model on top of Zend_Db would be greatly appreciated.

                  推荐答案

                  域模型不扩展任何内容.它们只是用于封装业务逻辑的普通类.他们可能使用数据访问对象,所以在类内部可能有一个行数据网关对象的protected实例.Row 对象通常比 Table 对象更接近地表示域的实例.此外,您始终可以使用RowgetTable() 方法获取Table 对象.

                  Domain Models extend nothing. They're just plain classes you use to encapsulate business logic. They may use data access objects, so there may be a protected instance of a row data gateway object inside the class. A Row object usually represents an instance of the domain more closely than a Table object. Besides, you can always get the Table object with the Row's getTable() method.

                  通常,DM 类具有一个接口,其中包含与您可以使用该类执行的更高级别操作相对应的方法.但您不一定要显示所有数据访问操作.

                  Typically DM classes have an interface with methods corresponding to higher-level operations you can do with that class. But you don't necessarily want to surface all data access operations.

                  class Person {
                    // Zend_Db_Table_Row object
                    protected $data; 
                  
                    public function subscribeToService(Service $service) { ... }
                  
                    public function sendMailTo(Person $recipient) { ... }
                  
                    public function changePassword($newPassword) { ... }
                  }
                  

                  我去年 春季也写了关于这个主题的博客,并在 ZF 邮件列表上写了它 最近.

                  I also blogged about this subject last spring, and wrote about it on the ZF mailing list recently.

                  就教程和资源而言,请尝试 http://domaindrivendesign.org/

                  As far as tutorials and resources, try http://domaindrivendesign.org/

                  这篇关于如何使用 Zend Framework 正确创建域?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:Zend_Test_PHPUnit_Constraint_DomQuery::evaluate() 的声明应该 下一篇:Zend_Db 没有 Zend 框架

                  相关文章

                  最新文章

                    <bdo id='GNJna'></bdo><ul id='GNJna'></ul>
                2. <legend id='GNJna'><style id='GNJna'><dir id='GNJna'><q id='GNJna'></q></dir></style></legend>
                    <i id='GNJna'><tr id='GNJna'><dt id='GNJna'><q id='GNJna'><span id='GNJna'><b id='GNJna'><form id='GNJna'><ins id='GNJna'></ins><ul id='GNJna'></ul><sub id='GNJna'></sub></form><legend id='GNJna'></legend><bdo id='GNJna'><pre id='GNJna'><center id='GNJna'></center></pre></bdo></b><th id='GNJna'></th></span></q></dt></tr></i><div id='GNJna'><tfoot id='GNJna'></tfoot><dl id='GNJna'><fieldset id='GNJna'></fieldset></dl></div>

                      <tfoot id='GNJna'></tfoot>

                      <small id='GNJna'></small><noframes id='GNJna'>