signal-manager 仿django的信号系统

  1. Documentation
  2. Change Log

仿django的信号处理系统 用途: 新添加的模块不改变核心代码捕获系统核心的事件的钩子

Resources

Documentation

Requirements
  • Yii 1.0 or above
Installation
  • Extract the release file under protected/extensions
Usage

See the following code example: 一添加组建到config

'signalManager'=>array(
            'class'=>'ext.signal.PPhpSignalManager',
        ),

二在模型所在目录给模型添加需要处理的信号配置文件,模型名_reciever.php

<?php

return array(
    array(
        'signal'=>'TestSignal',
        'method'=>'testSignal',
    ),
    array(
        'signal'=>'MemberLogin',
        'method'=>'testSignal',
    ),
);

三 使用

public function actionTest()
    {
        $signalManager = Yii::app()->signalManager;
        $signalManager->send('MemberLogin', new CEvent(xxxx));
    }

这样便会触发member模型调用testSignal静态方法处理该事件,仓促写出的,各种情况可能得在使用时该进

Change Log

May 30, 2010
  • Initial release.
0 2
1 follower
319 downloads
Yii Version: 1.1
License: BSD-2-Clause
Category: Others
Tags:
Developed by: puper
Created on: May 30, 2010
Last updated: 14 years ago

Downloads

show all