是否有观察者事件的完整列表? [英] Is there a comprehensive list of observer events?

查看:63
本文介绍了是否有观察者事件的完整列表?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否存在可以监听的所有事件的完整列表?

Is there a comprehensive list of all events that can be listened for?

如果此列表不存在,那么调试所有事件的最佳方法是什么?

If this list doesn't exist, what's the best method to debug to obtain all events?

推荐答案

您将永远找不到完整的列表.但是,如果您转到app/Mage.php,则可以在函数"dispatchEvent()"中放入一些调试代码,并在运行时记录所有事件.

You'll never find a complete list. But if you go to app/Mage.php you can put in some debug code inside of the function "dispatchEvent()" and log all of the events as you go.

$params = array();
foreach (array_keys($data) as $key) {
    if (is_object($data[$key])) {
        $params[] = $key.' ('.get_class($data[$key]).')';
    } else {
        $params[] = $key.' ('.gettype($data[$key]).')';
    }
}
Mage::log('event_name:'.$name.',event_passed_keys:'.implode('|',$params),null,'events.log',true);

然后使用一些excel向导,可以将其解析为所有传递给它的事件名称和参数的列表.

Then using some excel wizardry you can parse those out into a list of all of the event names and parameters being passed to it.

许多已编译列表甚至执行grep的问题都在于,动态创建了许多事件.通过该功能,您可以识别未列出的事件.

The problem with many of the compiled lists or even doing the grep as shown above is that many of the events are dynamically created. Which lets you discern what events there are that aren't listed.

请确保注释掉调试代码或events.log文件将在短时间内变得很大.

Make sure to comment out that debug code or the events.log file will become huge after just a short time.

这篇关于是否有观察者事件的完整列表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆