Event.php 1.53 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 20
 * uninvoked handlers will no longer be called to handle the event.
 * Additionally, an event may specify extra parameters via the [[params]] 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 Component
Qiang Xue committed
26
{
w  
Qiang Xue committed
27 28 29 30 31 32
	/**
	 * @var string the event name. This property is set by [[Component::raiseEvent]].
	 * Event handlers may use this property to check what event it is handling.
	 * The event name is in lower case.
	 */
	public $name;
Qiang Xue committed
33 34 35 36 37 38
	/**
	 * @var object the sender of this event
	 */
	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 44 45 46
	/**
	 * @var mixed extra parameters associated with the event.
	 */
	public $params;
Qiang Xue committed
47 48 49 50 51

	/**
	 * Constructor.
	 * @param mixed $sender sender of the event
	 */
w  
Qiang Xue committed
52
	public function __construct($sender=null, $params=null)
Qiang Xue committed
53
	{
w  
Qiang Xue committed
54
		$this->sender = $sender;
w  
Qiang Xue committed
55
		$this->params = $params;
Qiang Xue committed
56 57
	}
}