Zend 应用程序的设计建议

发布于 2024-07-30 17:17:06 字数 352 浏览 11 评论 0原文

寻求一些建议\对我的应用程序结构的改进

用户登录并显示欢迎消息和选项菜单 每个选项都指向相同的控制器,例如 OptionController,但具有不同的操作

/option/abc
/option/def

OptionController.php
{
abcAction()
defAction()
}

我有不同操作的原因是因为

当呈现表单并且用户输入输入时,每个选项都需要不同的表单,请求将再次提交到验证控制器,每个选项有不同的操作。 我需要基本的表单验证+自定义业务逻辑,

我让它“工作”,但不认为这是一个好方法。 想法?

Looking for some advice \ improvements on the structure of my application

user logs in and is presented with a welcome message and a menu of options
each option points to the same controller e.g OptionController but with different actions

/option/abc
/option/def

OptionController.php
{
abcAction()
defAction()
}

the reason why I have different actions is because each option will require a different form

when the form is rendered and the user enters input the request is submitted to a validate controller again with a different action per option. i need basic form validation + custom business logic

I have it "working" but don't think it's a good way to do it. Thoughts?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

Spring初心 2024-08-06 17:17:06

我建议您总结的结构不是任务的艺术(显示、验证),而是用您的话来说,

例如“选项”(:

controller: abcController
actions:    addAction()
            editAction()
            listAction()
            viewAction()
            deleteAction()


controller: defController
actions:    addAction()
            editAction()
            listAction()
            viewAction()
            deleteAction()

表单的配置(包括验证)应该位于从 Zend_Form 扩展的自己的类中)存储在其自己的文件夹中,例如 APPLICATION_PATH.'/forms'(请参阅 ZF - 自动加载器),显示和验证表单可以驻留在同一操作中,我通常将它们拆分为添加和编辑(但使用相同的表单类)。两者)

您在所有控制器中需要的任务最好作为操作或视图助手来实现。

I would recommend a structure where you summarize not the art (display, validated) of task, but the, in your words, "options"

for example (:

controller: abcController
actions:    addAction()
            editAction()
            listAction()
            viewAction()
            deleteAction()


controller: defController
actions:    addAction()
            editAction()
            listAction()
            viewAction()
            deleteAction()

the configs for your forms (including validation) should be in own classes extended from Zend_Form which are stored in its own folder. eg APPLICATION_PATH.'/forms'. (see ZF - autoloader) displaying and validating forms can reside in the same action, i usaly split them into add and edit. (but using the same form class for both)

task's you need in all controllers are best to be implemented as action or view helpers.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文