当事件触发的时候...

会循环所有behavior的events  为ower添加事件.....AttributeBehavior  为事件添加如下方法

	public function evaluateAttributes($event)
{
if (!empty($this->attributes[$event->name])) {
$attributes = (array)$this->attributes[$event->name];
$value = $this->getValue($event);
foreach ($attributes as $attribute) {
$this->owner->$attribute = $value;
}
}
}

  

可以看到..循环所有特性...根据getValue获取所有特性...并设置owner的值...

AttributeBehavior的更多相关文章

  1. Yii2的深入学习--行为Behavior

    我们先来看下行为在 Yii2 中的使用,如下内容摘自 Yii2中文文档 行为是 [[yii\base\Behavior]] 或其子类的实例.行为,也称为 mixins,可以无须改变类继承关系即可增强一 ...

  2. yii 核心类classes.php详解(持续更新中...)

    classes.php在yii运行的时候将被自动加载,位于yii2文件夹底下. <?php /** * Yii core class map. * * This file is automati ...

  3. Yii2 TimestampBehavior行为

    <?php /** * @link http://www.yiiframework.com/ * @copyright Copyright (c) 2008 Yii Software LLC * ...

  4. 忘记时间戳的存在——Yii2超实用的自动更新时间戳的Behavior(改进版)

    本文改进了Yii2中内置行为类TimestampBehavior,使得时间戳字段(如created_at,updated_at) 完全自己更新,方便得让你忘记它们的存在. Yii2的内置行为类Time ...

  5. Yii2基本概念之——行为(Behavior)

    使用行为(behavior)可以在不修改现有类的情况下,对类的功能进行扩充.通过将行为绑定到一个类,可以使得类具有行为本身所具有的属性和方法,就好像是类本来就具有的这些属性和功能一样. 好的代码设计, ...

随机推荐

  1. codeforces 260 div2 B题

    打表发现规律,对4取模为0的结果为4,否则为0,因此只需要判断输入的数据是不是被4整出即可,数据最大可能是100000位的整数,判断能否被4整出不能直接去判断,只需要判断最后两位(如果有)或一位能否被 ...

  2. Qt Style Sheets制作UI特效

    使用Qt Style Sheets制作UI特效  博客出处:http://developer.nokia.com/community/wiki/%E4%BD%BF%E7%94%A8Qt_Style_S ...

  3. OnItemClickListener 的参数详解(转)

    转载地址:http://blog.iamzsx.me/show.html?id=147001 我们在使用ListView的时候,一般都会为ListView添加一个响应事件android.widget. ...

  4. 一个使用微软Azure blob实现文件下载功能的实例-附带源文件

    Running the sample Please follow the steps below. Step 1: Open the CSAzureServeFilesFromBlobStorage. ...

  5. sql-case列转行

    1:对列进行逻辑判断 select ID,Score, case when Score>=90 then 'A' when Score>=80 then 'B' when Score> ...

  6. OpenCV中IplImage和Mat间的相互转换

    OpenCV中做图像处理经常用到IplImage和Mat间的相互转换. 首先,cv::Mat是opencv2.0中的数据类型:IplImage是opencv1.0中的类型,两种类型并不相同. 1. I ...

  7. java类加载与初始化

    第一段: class A{ public A(){ this.list(); } public void list(){ System.out.println("in a list..&qu ...

  8. mongodb 新建用户 -摘自网络

    随着版本的更新,对在使用mongodb的业务也进行了版本升级,但是在drop掉一个数据库时,问题来了,原来的用户随着删除库也被删除掉,但是再想通过原来的语法db.addUser()添加,一直报错,提示 ...

  9. 设置sonar 界面为中文环境

    sonar 默认是英文的界面 1.下载http://repository.codehaus.org/org/codehaus/sonar-plugins/l10n/sonar-l10n-zh-plug ...

  10. Educational Codeforces Round 14 D. Swaps in Permutation (并查集orDFS)

    题目链接:http://codeforces.com/problemset/problem/691/D 给你n个数,各不相同,范围是1到n.然后是m行数a和b,表示下标为a的数和下标为b的数可以交换无 ...