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.

103 lines
3.0 KiB

14 years ago
<?php
/**
13 years ago
* ActiveRecordBehavior class file.
14 years ago
*
* @link http://www.yiiframework.com/
* @copyright Copyright &copy; 2008 Yii Software LLC
14 years ago
* @license http://www.yiiframework.com/license/
*/
namespace yii\db;
13 years ago
use yii\base\ModelBehavior;
14 years ago
/**
13 years ago
* ActiveRecordBehavior is the base class for behaviors that can be attached to [[ActiveRecord]].
*
* Compared to [[\yii\base\ModelBehavior]], ActiveRecordBehavior responds to more events
* that are specific to [[ActiveRecord]].
14 years ago
*
* @author Qiang Xue <qiang.xue@gmail.com>
13 years ago
* @since 2.0
14 years ago
*/
13 years ago
class ActiveRecordBehavior extends ModelBehavior
14 years ago
{
/**
* Declares events and the corresponding event handler methods.
* If you override this method, make sure you merge the parent result to the return value.
* @return array events (array keys) and the corresponding event handler methods (array values).
13 years ago
* @see \yii\base\Behavior::events()
14 years ago
*/
public function events()
{
return array_merge(parent::events(), array(
13 years ago
'beforeInsert' => 'beforeInsert',
'afterInsert' => 'afterInsert',
'beforeUpdate' => 'beforeUpdate',
'afterUpdate' => 'afterUpdate',
'beforeDelete' => 'beforeDelete',
'afterDelete' => 'afterDelete',
14 years ago
));
}
/**
13 years ago
* Responds to the owner's `beforeInsert` event.
* Overrides this method if you want to handle the corresponding event of the owner.
* You may set the [[ModelEvent::isValid|isValid]] property of the event parameter
* to be false to quit the ActiveRecord inserting process.
* @param \yii\base\ModelEvent $event event parameter
14 years ago
*/
13 years ago
public function beforeInsert($event)
14 years ago
{
}
/**
13 years ago
* Responds to the owner's `afterInsert` event.
* Overrides this method if you want to handle the corresponding event of the owner.
* @param \yii\base\ModelEvent $event event parameter
14 years ago
*/
13 years ago
public function afterInsert($event)
{
}
/**
13 years ago
* Responds to the owner's `beforeUpdate` event.
* Overrides this method if you want to handle the corresponding event of the owner.
* You may set the [[ModelEvent::isValid|isValid]] property of the event parameter
* to be false to quit the ActiveRecord updating process.
* @param \yii\base\ModelEvent $event event parameter
13 years ago
*/
public function beforeUpdate($event)
{
}
/**
13 years ago
* Responds to the owner's `afterUpdate` event.
* Overrides this method if you want to handle the corresponding event of the owner.
* @param \yii\base\ModelEvent $event event parameter
13 years ago
*/
public function afterUpdate($event)
14 years ago
{
}
/**
13 years ago
* Responds to the owner's `beforeDelete` event.
* Overrides this method if you want to handle the corresponding event of the owner.
* You may set the [[ModelEvent::isValid|isValid]] property of the event parameter
* to be false to quit the ActiveRecord deleting process.
* @param \yii\base\ModelEvent $event event parameter
14 years ago
*/
public function beforeDelete($event)
{
}
/**
13 years ago
* Responds to the owner's `afterDelete` event.
* Overrides this method if you want to handle the corresponding event of the owner.
* @param \yii\base\ModelEvent $event event parameter
14 years ago
*/
public function afterDelete($event)
{
}
}