Zend Framework 1.10 重写类调用?
我想我试图变得过于聪明。如果有效的话,耶。如果没有,不用担心。
我希望我的应用程序尽可能模块化。目前我只有一个产品模块,但根据经验,我知道我可能还需要一个类别模块,其中产品将是其子模块。虽然类别模块不存在,但我希望调用 Products_Forms_NewProduct 等来加载该表单。当类别模块放入应用程序时,我希望它能够被自动检测并转发任何调用,例如,将 Products_Forms_NewProduct 转发到 Categories_Forms_NewProduct。
我该怎么办?
I think I am trying to be overly clever. If it works, yay. If not, no worries.
I want my application to be as modular as possible. At the moment I have just a products module but from experience I know I might want a categories module as well, in which products will be children of. Whilst the categories module does not exist I want calls to, for example, Products_Forms_NewProduct to load that form. When the categories module is dropped into the application I want it to be automatically detected and forward any calls for, for example, Products_Forms_NewProduct to Categories_Forms_NewProduct.
How do I go about this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在我看来,您正在寻找依赖注入。但我建议开设一个可以适当修改表格的课程。就像一个表单插件。这不是扩展,而是组合。我会遵循这些原则:
You're looking for dependency injection IMO. But I'd suggest having a class that would modify the form appropriately. Like a form-plugin. This is no case of extension, but rather composition. I'd go with something alon those lines: