回调对象优先级

你可以优先触发对象回调类似事件回调。优先级值的处理和订单触发解释相同。这里是如何指定优先级在申报时间:

class SomeController {
    public $components = array(
        'Foo', //Foo gets default priority 10
        // Bar's callbacks are triggered before Foo's
        'Bar' => array('priority' => 9)
    );

    public $helpers = array(
        // Cache's callbacks will be triggered last
        'Cache' => array('priority' => 12),
        'Asset',
        'Utility' //Utility has priority 10 same as Asset and its callbacks
                  //are triggered after Asset's
    );
}


class Post {
    public $actsAs = array(
        'DoFirst' => array('priority' => 1),
        'Media'
    );
}


动态加载对象集合时您可以指定优先级如下:
$this->MyComponent = $this->Components->load(
    'MyComponent',
    array('priority' => 9)
);
你也可以在运行时改变优先级使用ObjectCollection::setPriority()函数:
//For a single object
$this->Components->setPriority('Foo', 2);

//For multiple objects
$this->Behaviors->setPriority(array('Object1' => 8, 'Object2' => 9));


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值