Zend_Auth:为什么验证名为适配器而不是策略的对象?

发布于 2024-07-29 20:37:34 字数 86 浏览 2 评论 0原文

$Zend_auth->authenticate($adapter);

为什么称为适配器而不是策略?

$Zend_auth->authenticate($adapter);

Why is it called an adapter and not a strategy?

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

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

发布评论

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

评论(1

夜声 2024-08-05 20:37:34

好问题科恩。 我同意 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.

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