Event.php 1.55 KB
Newer Older
Qiang Xue committed
1
<?php
w  
Qiang Xue committed
2 3 4 5 6 7 8
/**
 * Event class file.
 *
 * @link http://www.yiiframework.com/
 * @copyright Copyright &copy; 2008-2012 Yii Software LLC
 * @license http://www.yiiframework.com/license/
 */
Qiang Xue committed
9 10 11 12

namespace yii\base;

/**
Qiang Xue committed
13
 * Event is the base class for all event classes.
Qiang Xue committed
14 15
 *
 * It encapsulates the parameters associated with an event.
w  
Qiang Xue committed
16 17 18
 * 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
19
 * uninvoked handlers will no longer be called to handle the event.
Qiang Xue committed
20
 * Additionally, an event may specify extra parameters via the [[data]] property.
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 \yii\base\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 33 34 35 36 37
	/**
	 * @var object the sender of this event
	 */
	public $sender;
	/**
	 * @var boolean whether the event is handled. Defaults to false.
w  
Qiang Xue committed
38 39
	 * 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
40
	 */
Qiang Xue committed
41
	public $handled = false;
m  
Qiang Xue committed
42
	/**
Qiang Xue committed
43
	 * @var mixed extra data associated with the event.
m  
Qiang Xue committed
44
	 */
Qiang Xue committed
45
	public $data;
Qiang Xue committed
46 47 48

	/**
	 * Constructor.
Alexander Makarov committed
49
	 *
Qiang Xue committed
50
	 * @param mixed $sender sender of the event
Qiang Xue committed
51
	 * @param mixed $data extra data associated with the event
Qiang Xue committed
52
	 */
Qiang Xue committed
53
	public function __construct($sender = null, $data = null)
Qiang Xue committed
54
	{
w  
Qiang Xue committed
55
		$this->sender = $sender;
Qiang Xue committed
56
		$this->data = $data;
Qiang Xue committed
57 58
	}
}