yii\base\Behaviors

A behavior can be used to enhance the functionality of an existing component without modifying its code. In particular, it can "inject" its own methods and properties into the component and make them directly accessible via the component. It can also respond to the events triggered in the component and thus intercept the normal code execution.

行为(Behaviors)

在Yii框架中,行为实现了Mixin模式。它们可以增强组件的功能,但是不用修改组件的代码; 行为还可以响应在组件中触发的事件,从而拦截正常代码的执行。与PHPTraits不同,behaviors可以在代码运行时,附加到类。

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容