Zend_Auth:为什么验证名为适配器而不是策略的对象?
$Zend_auth->authenticate($adapter);
为什么称为适配器而不是策略?
$Zend_auth->authenticate($adapter);
Why is it called an adapter and not a strategy?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
好问题科恩。 我同意 Zend_Auth_Adapter 组件是策略模式的良好代表。 可以说它也是适配器模式的候选者。 它充当您正在使用的任何身份验证机制的适配器,这可能是另一个类(使其更明显是一个适配器),但即使对于诸如使用存储在数据库中的凭据进行身份验证之类的事情,它< em>作为底层凭证存储的简单英语适配器。
此外,Zend Framework 中没有约定通过模式名称来调用每个类。 尽管存在适合这些模式的类,但不存在 Xxx_Singleton、Xxx_Strategy 或 Xxx_Builder 类。 然而,同时还有 Xxx_Decorator 类。
最重要的是,从最早的时候起,它就是一个提案< /a> 它被称为适配器。 ZF 社区接受了这一点,没有人反对它的命名。 因此,它被采用到框架中,并且可能永远被称为 Zend_Auth_Adapter。
Good question koen. I'd agree that the Zend_Auth_Adapter component is a good representation of the Strategy pattern. An argument could be made that it is a candidate for the Adapter pattern as well. It is serving as an adapter to whatever authentication mechanism you are using, which could be another class (making this more obviously an Adapter), but even for something such as authentication using credentials stored in a database it is serving as a plain-english adapter to your underlying credential store.
Also, there is no convention in the Zend Framework to call each class by it's pattern name. There are no Xxx_Singleton, Xxx_Strategy, or Xxx_Builder classes despite there being classes that fit these patterns. Yet, at the same time there are Xxx_Decorator classes.
Most importantly, from it's earliest days as a proposal it was referred to as an Adapter. The ZF community accepted this, and noone objected to it's naming. Thus, it was adopted into the framework and will likely forever be known as Zend_Auth_Adapter.