Event.php 1.66 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
 * Additionally, an event may specify extra parameters via the [[data]] property.
Qiang Xue committed
19 20
 *
 * @author Qiang Xue <qiang.xue@gmail.com>
w  
Qiang Xue committed
21
 * @since 2.0
Qiang Xue committed
22
 */
Qiang Xue committed
23
class Event extends \yii\base\Object
Qiang Xue committed
24
{
w  
Qiang Xue committed
25
	/**
Qiang Xue committed
26
	 * @var string the event name. This property is set by [[Component::trigger()]].
w  
Qiang Xue committed
27 28 29
	 * Event handlers may use this property to check what event it is handling.
	 */
	public $name;
Qiang Xue committed
30 31 32 33 34 35
	/**
	 * @var object the sender of this event
	 */
	public $sender;
	/**
	 * @var boolean whether the event is handled. Defaults to false.
w  
Qiang Xue committed
36 37
	 * 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
38
	 */
Qiang Xue committed
39
	public $handled = false;
m  
Qiang Xue committed
40
	/**
Qiang Xue committed
41
	 * @var mixed extra data associated with the event.
m  
Qiang Xue committed
42
	 */
Qiang Xue committed
43
	public $data;
Qiang Xue committed
44 45 46

	/**
	 * Constructor.
Alexander Makarov committed
47
	 *
Qiang Xue committed
48
	 * @param mixed $sender sender of the event
Qiang Xue committed
49
	 * @param mixed $data extra data associated with the event
Qiang Xue committed
50
	 * @param array $config name-value pairs that will be used to initialize the object properties
Qiang Xue committed
51
	 */
Qiang Xue committed
52
	public function __construct($sender = null, $data = null, $config = array())
Qiang Xue committed
53
	{
w  
Qiang Xue committed
54
		$this->sender = $sender;
Qiang Xue committed
55
		$this->data = $data;
Qiang Xue committed
56
		parent::__construct($config);
Qiang Xue committed
57 58
	}
}