| 状态 | 草稿 |
|---|---|
| Todo | What events are, how events work, running, adding, using custom |
| Todo | Move stuff from core:event |
| 官方最后更新时间 | 2009/01/30 08:41 |
关于事件的添加,运行,删除,自定义事件详细信息请看 事件类(Event Class)。
Kohana 事件的组成是由事件名和 callback 组成1)。事件名一般带有前缀。但这不是必须,所有的 核心库(Core)事件 都是以 system 为前缀,例如:system.name。
下列事件的定义均在 Kohana 核心库文件中。为这些事件预定义的动作均在 Kohana::setup 中。
当钩子(hooks )加载后立即调用此事件。这个事件是最早可捕捉的事件。钩子加载之前,默认情况下没有附加到这个事件上。
运行过程中网址是否路由。默认情况下调用 Calls Router::find_uri 和 Router::setup。
控制器的定位和初始化。当控制器对象作为 Kohan 实例被创建时,默认情况下调用 Kohana::instance。
在所有的 routing 执行完成后触发此事件,如果 Router::$controller 为空则触发 404 事件。
当页面没有找到时调用此事件。默认情况下调用 Kohana::show_404。
在控制器加载之后但在对象创建之前同 system.execute 一起调用。
在控制器的构造器被调用后同 system.execute 一起调用。Kohana::instance 在这点返回控制器。控制器方法
Called within system.execute, after the controller constructor has been called. Kohana::instance will return the controller at this point, and views can be loaded. Controller methods have not been called yet.
Called within system.execute, after the controller object is created. Kohana::instance will return the controller at this point, and views can be loaded.
Called just before the global output buffer is closed, before any content is displayed. Writing cookies is not possible after this point, and Session data will not be saved.
显示输出 Kohana 系统已经运行。视图被加载,但是头信息(headers )已经发送。rendered 输出可以作为被操纵的,就像 Event::$data。
原文: Displays the output that Kohana has generated. Views can be loaded, but headers have already been sent. The rendered output can be manipulated as Event::$data.
在 PHP 结束(关闭)之前最后运行的事件,默认情况下运行 Kohana::shutdown 方法。
同 Kohana::log 一起调用。如果你想在不同的地方记录或存储某些事件的日志信息使用它发送邮件是一个不错的方式。
同 url::redirect 一起调用。可以很好的用于系统执行重定向。
钩子在 Kohana 系统运行前期加载,它可以执行代码前被使用,举例说,控制器被加载这样您就可以检查相关事项(比如在 Kohana 系统运行前期进行验证)。事件和钩子可以配合使用。相辅相成的。详情请参见 钩子(Hooks) 页面。
原文: Hooks are included early in Kohana and can be used to execute code before e.g. controllers are loaded so you can check for for example authentication early in Kohana. Events and hooks go hand in hand since in hooks you can attach code to events. See for more information the Hooks page.