Event.php 1.55 KB
Newer Older
Qiang Xue committed
1
<?php
w  
Qiang Xue committed
2 3
/**
 * @link http://www.yiiframework.com/
Qiang Xue committed
4
 * @copyright Copyright (c) 2008 Yii Software LLC
w  
Qiang Xue committed
5 6
 * @license http://www.yiiframework.com/license/
 */
Qiang Xue committed
7 8 9 10

namespace yii\base;

/**
Qiang Xue committed
11
 * Event is the base class for all event classes.
Qiang Xue committed
12 13
 *
 * It encapsulates the parameters associated with an event.
w  
Qiang Xue committed
14 15 16
 * The [[sender]] property describes who raises the event.
 * And the [[handled]] property indicates if the event is handled.
 * If an event handler sets [[handled]] to be true, the rest of the
m  
Qiang Xue committed
17
 * uninvoked handlers will no longer be called to handle the event.
Qiang Xue committed
18 19 20
 *
 * Additionally, when attaching an event handler, extra data may be passed
 * and be available via the [[data]] property when the event handler is invoked.
Qiang Xue committed
21 22
 *
 * @author Qiang Xue <qiang.xue@gmail.com>
w  
Qiang Xue committed
23
 * @since 2.0
Qiang Xue committed
24
 */
Qiang Xue committed
25
class Event extends Object
Qiang Xue committed
26
{
w  
Qiang Xue committed
27
	/**
Qiang Xue committed
28
	 * @var string the event name. This property is set by [[Component::trigger()]].
w  
Qiang Xue committed
29 30 31
	 * Event handlers may use this property to check what event it is handling.
	 */
	public $name;
Qiang Xue committed
32
	/**
Qiang Xue committed
33 34
	 * @var object the sender of this event. If not set, this property will be
	 * set as the object whose "trigger()" method is called.
Qiang Xue committed
35 36 37 38
	 */
	public $sender;
	/**
	 * @var boolean whether the event is handled. Defaults to false.
w  
Qiang Xue committed
39 40
	 * When a handler sets this to be true, the event processing will stop and
	 * ignore the rest of the uninvoked event handlers.
Qiang Xue committed
41
	 */
Qiang Xue committed
42
	public $handled = false;
m  
Qiang Xue committed
43
	/**
Qiang Xue committed
44 45
	 * @var mixed the data that is passed to [[Component::on()]] when attaching an event handler.
	 * Note that this varies according to which event handler is currently executing.
m  
Qiang Xue committed
46
	 */
Qiang Xue committed
47
	public $data;
Qiang Xue committed
48
}