Yii2 Bootstrap 3
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

72 lines
1.9 KiB

14 years ago
<?php
/**
14 years ago
* ModelBehavior class file.
14 years ago
*
* @link http://www.yiiframework.com/
14 years ago
* @copyright Copyright &copy; 2008-2012 Yii Software LLC
14 years ago
* @license http://www.yiiframework.com/license/
*/
14 years ago
namespace yii\base;
14 years ago
/**
14 years ago
* ModelBehavior class.
*
* ModelBehavior is a base class for behaviors that are attached to a model object.
* The model should be an instance of [[Model]] or its child classes.
*
14 years ago
* @author Qiang Xue <qiang.xue@gmail.com>
14 years ago
* @since 2.0
14 years ago
*/
14 years ago
class ModelBehavior extends Behavior
14 years ago
{
/**
14 years ago
* Declares event handlers for owner's events.
13 years ago
* The default implementation returns the following event handlers:
14 years ago
*
13 years ago
* - `onAfterInit` event: [[afterInit]]
14 years ago
* - `onBeforeValidate` event: [[beforeValidate]]
* - `onAfterValidate` event: [[afterValidate]]
*
* You may override these event handler methods to respond to the corresponding owner events.
14 years ago
* @return array events (array keys) and the corresponding event handler methods (array values).
*/
public function events()
{
return array(
13 years ago
'onAfterInit' => 'afterInit',
14 years ago
'onBeforeValidate' => 'beforeValidate',
'onAfterValidate' => 'afterValidate',
14 years ago
);
}
/**
13 years ago
* Responds to [[Model::onAfterInit]] event.
13 years ago
* Override this method if you want to handle the corresponding event of the [[owner]].
14 years ago
* @param Event $event event parameter
14 years ago
*/
13 years ago
public function afterInit($event)
14 years ago
{
}
/**
14 years ago
* Responds to [[Model::onBeforeValidate]] event.
13 years ago
* Override this method if you want to handle the corresponding event of the [[owner]].
13 years ago
* You may set the [[ModelEvent::isValid|isValid]] property of the event parameter
14 years ago
* to be false to cancel the validation process.
13 years ago
* @param ModelEvent $event event parameter
14 years ago
*/
public function beforeValidate($event)
{
}
/**
14 years ago
* Responds to [[Model::onAfterValidate]] event.
13 years ago
* Override this method if you want to handle the corresponding event of the [[owner]].
14 years ago
* @param Event $event event parameter
14 years ago
*/
public function afterValidate($event)
{
}
}