Yii2 framework backup
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

13 years ago
<?php
/**
13 years ago
* ModelBehavior class file.
13 years ago
*
* @link http://www.yiiframework.com/
13 years ago
* @copyright Copyright &copy; 2008-2012 Yii Software LLC
13 years ago
* @license http://www.yiiframework.com/license/
*/
13 years ago
namespace yii\base;
13 years ago
/**
13 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.
*
13 years ago
* @author Qiang Xue <qiang.xue@gmail.com>
13 years ago
* @since 2.0
13 years ago
*/
13 years ago
class ModelBehavior extends Behavior
13 years ago
{
/**
13 years ago
* Declares event handlers for owner's events.
13 years ago
* The default implementation returns the following event handlers:
13 years ago
*
13 years ago
* - `onAfterInit` event: [[afterInit]]
13 years ago
* - `onBeforeValidate` event: [[beforeValidate]]
* - `onAfterValidate` event: [[afterValidate]]
*
* You may override these event handler methods to respond to the corresponding owner events.
13 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',
13 years ago
'onBeforeValidate' => 'beforeValidate',
'onAfterValidate' => 'afterValidate',
13 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]].
13 years ago
* @param Event $event event parameter
13 years ago
*/
13 years ago
public function afterInit($event)
13 years ago
{
}
/**
13 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 [[ValidationEvent::isValid|isValid]] property of the event parameter
* to be false to cancel the validation process.
* @param ValidationEvent $event event parameter
13 years ago
*/
public function beforeValidate($event)
{
}
/**
13 years ago
* Responds to [[Model::onAfterValidate]] event.
13 years ago
* Override this method if you want to handle the corresponding event of the [[owner]].
13 years ago
* @param Event $event event parameter
13 years ago
*/
public function afterValidate($event)
{
}
}