本文整理汇总了PHP中CActiveRecordBehavior类的典型用法代码示例。如果您正苦于以下问题:PHP CActiveRecordBehavior类的具体用法?PHP CActiveRecordBehavior怎么用?PHP CActiveRecordBehavior使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CActiveRecordBehavior类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: beforeSave
/**
* Triggered before the model saves, this is where the slug attribute is actually set
* @see CActiveRecordBehavior::beforeSave()
*/
public function beforeSave($event)
{
if ($this->owner->isNewRecord || $this->owner->{$this->slugAttribute} == "") {
$this->owner->{$this->slugAttribute} = $this->createSlug();
}
return parent::beforeSave($event);
}
开发者ID:niranjan2m,项目名称:Voyanga,代码行数:11,代码来源:ASluggable.php
示例2: attach
/**
* @param CActiveRecord $owner
*/
public function attach($owner)
{
$validator = new yupe\components\validators\NumberValidator();
$validator->attributes = array($this->priceAttribute, $this->priceEurAttribute, $this->priceOldAttribute);
$owner->getValidatorList()->add($validator);
parent::attach($owner);
}
开发者ID:kuzmina-mariya,项目名称:unizaro-decor,代码行数:10,代码来源:PriceBehavior.php
示例3: attach
/**
* @param CActiveRecord $owner
*/
public function attach($owner)
{
$validator = new CSafeValidator();
$validator->attributes = array($this->attribute);
$owner->getValidatorList()->add($validator);
parent::attach($owner);
}
开发者ID:kuzmina-mariya,项目名称:gallery,代码行数:10,代码来源:DMultiplyListBehavior.php
示例4: afterValidate
public function afterValidate($event)
{
parent::afterValidate($event);
if ($this->checkScenario() && !$this->owner->hasErrors()) {
$modelName = get_class($this->owner);
if (isset($_FILES[$modelName]['name'][$this->attributeName])) {
$files = array();
foreach ($_FILES[$modelName] as $k => $v) {
$files[$k] = $v[$this->attributeName];
}
// Сохраняю
if ($files) {
Yii::import('ext.ImageUpload.ImageUpload');
$handle = new ImageUpload($files);
if ($handle->uploaded) {
$this->saveImage($handle);
// Удаляю старую фотку
if ($this->owner->scenario == 'update') {
$this->deleteImage();
}
$handle->clean();
}
unset($handle, $files);
}
}
}
}
开发者ID:mmorpg2015,项目名称:ghtweb5,代码行数:27,代码来源:ImageUploadBehavior.php
示例5: attach
public function attach($owner)
{
parent::attach($owner);
$this->_hasCreateDate = $this->getOwner()->hasAttribute('createDate');
$this->_hasLastUpdated = $this->getOwner()->hasAttribute('lastUpdated');
$this->_hasLastActivity = $this->getOwner()->hasAttribute('lastActivity');
}
开发者ID:tymiles003,项目名称:X2CRM,代码行数:7,代码来源:X2TimestampBehavior.php
示例6: beforeSave
public function beforeSave($event)
{
if ($this->_value !== NULL) {
$this->getOwner()->setAttribute($this->getBackupAttribute(), $this->_value);
}
return parent::beforeSave($event);
}
开发者ID:sinelnikof,项目名称:yiiext,代码行数:7,代码来源:ELastValueBehavior.php
示例7: attach
/**
* @param CComponent $owner
*/
public function attach($owner)
{
$owner->attachEventHandler('onProductAdded', array($this, 'productAddedEvent'));
$owner->attachEventHandler('onProductDeleted', array($this, 'productDeletedEvent'));
$owner->attachEventHandler('onProductQuantityChanged', array($this, 'onProductQuantityChanged'));
parent::attach($owner);
}
开发者ID:kolbensky,项目名称:rybolove,代码行数:10,代码来源:HistoricalBehavior.php
示例8: attach
/**
* Attaches dynamic relations.
*
* @param CActiveRecord $owner owner
*
* @see CBehavior::attach()
*/
public function attach($owner)
{
parent::attach($owner);
$ownerClassName = get_class($owner);
$metaData = $owner->getMetaData();
$metaData->addRelation('parent', array(CActiveRecord::BELONGS_TO, $ownerClassName, $this->parentIdColumn));
}
开发者ID:hansenmakangiras,项目名称:disperindag,代码行数:14,代码来源:AdjacencyTreeBehavior.php
示例9: attach
/**
* (non-PHPdoc).
*
* @see CBehavior::attach()
*/
public function attach($owner)
{
parent::attach($owner);
if (!isset($this->defaultCounter)) {
$this->defaultCounter = $this->counters[0];
}
}
开发者ID:hansenmakangiras,项目名称:disperindag,代码行数:12,代码来源:ArCounterBehavior.php
示例10: afterSave
public function afterSave($event)
{
parent::afterSave($event);
// do not auto-create meta data information for meta data table itself (recursion).
if ($this->metaDataRelation == '_self_') {
return true;
}
// create new meta data record or just update modifiedBy/At columns
if ($this->resolveMetaDataModel() === null) {
$metaClassName = $this->owner->getActiveRelation($this->metaDataRelation)->className;
$metaModel = new $metaClassName();
$metaModel->id = $this->owner->id;
$metaModel->status = self::STATUS_ACTIVE;
$metaModel->language = Yii::app()->language;
$metaModel->owner = Yii::app()->user->id;
$primaryRole = key(Yii::app()->authManager->getRoles(Yii::app()->user->id));
$metaModel->checkAccessDelete = $primaryRole;
$metaModel->createdAt = date('Y-m-d H:i:s');
$metaModel->createdBy = Yii::app()->user->id;
$metaModel->model = get_class($this->owner);
} else {
$metaModel = $this->resolveMetaDataModel();
$metaModel->modifiedAt = date('Y-m-d H:i:s');
$metaModel->modifiedBy = Yii::app()->user->id;
}
$metaModel->save();
return true;
}
开发者ID:ranvirp,项目名称:rdp,代码行数:28,代码来源:P3MetaDataBehavior.php
示例11: afterSave
public function afterSave($event)
{
$relations = $this->getRelations();
foreach ($relations as $relation) {
if ($relation['type'] == CActiveRecord::MANY_MANY) {
$forAdd = array_diff($relation['value'], $relation['oldValue']);
foreach ($forAdd as $id) {
if ($id) {
$sql = 'INSERT INTO `' . $relation['m2mTable'] . '`
(`' . $relation['m2mThisField'] . '`, `' . $relation['m2mForeignField'] . '`)
VALUES (:this_field, :foreign_field)';
Yii::app()->getDb()->createCommand($sql)->bindValues(array('this_field' => $this->getOwner()->id, ':foreign_field' => $id))->execute();
}
}
$forRemove = array_diff($relation['oldValue'], $relation['value']);
foreach ($forRemove as $id) {
if ($id) {
$sql = 'DELETE IGNORE FROM `' . $relation['m2mTable'] . '`
WHERE `' . $relation['m2mThisField'] . '` = :this_field
AND `' . $relation['m2mForeignField'] . '` = :foreign_field';
Yii::app()->getDb()->createCommand($sql)->bindValues(array('this_field' => $this->getOwner()->id, ':foreign_field' => $id))->execute();
}
}
}
}
//Yii::app()->end();
parent::afterSave($event);
return true;
}
开发者ID:rosko,项目名称:Tempo-CMS,代码行数:29,代码来源:RelationsBehavior.php
示例12: beforeDelete
public function beforeDelete($event)
{
foreach ($this->findAllAttaches() as $attach) {
$attach->delete();
}
return parent::beforeDelete($event);
}
开发者ID:nizsheanez,项目名称:kur.ru,代码行数:7,代码来源:AttachmentBehavior.php
示例13: attach
/**
* Attaches the behavior object to the model.
*
* @param string $owner The component to which the behavior will be applied
*/
public function attach($owner)
{
parent::attach($owner);
if ($this->getModule() === null) {
// Resolve the module
if (isset($this->baseRoute)) {
// Try to extract it from $baseRoute (old custom modules)
$this->module = preg_replace('/\\/.*/', '', preg_replace('/^\\//', '', $this->baseRoute));
} else {
// Assume the model name is the same as the module/controller
// (also true of custom modules)
$this->module = strtolower(get_class($this->owner));
}
}
if (!isset($this->baseRoute)) {
$this->baseRoute = '/' . $this->module;
}
if (!isset($this->viewRoute)) {
$this->viewRoute = $this->baseRoute;
}
if (Yii::app()->params->isMobileApp) {
$this->viewRoute .= '/mobileView';
}
if (!isset($this->autoCompleteSource)) {
$this->autoCompleteSource = $this->baseRoute . '/getItems?modelType=' . get_class($this->owner);
}
}
开发者ID:dsyman2,项目名称:X2CRM,代码行数:32,代码来源:X2LinkableBehavior.php
示例14: detach
public function detach($owner)
{
parent::detach($owner);
$this->objectId = null;
$this->objectType = null;
$this->_oaa = null;
}
开发者ID:vasiliy-pdk,项目名称:aes,代码行数:7,代码来源:ObjectAuthAssignmentBehavior.php
示例15: attach
public function attach($owner)
{
parent::attach($owner);
$this->_model = $owner;
$this->addRelations();
$this->addSafeAttributes();
}
开发者ID:hit-shappens,项目名称:testapp,代码行数:7,代码来源:ExtendedARBehavior.php
示例16: afterDelete
/**
* @param CEvent $event
* @return mixed
*/
public function afterDelete($event)
{
Yii::import('application.modules.comments.models.Comment');
$pk = $this->getObjectPkAttribute();
Comment::model()->deleteAllByAttributes(array('class_name' => $this->getClassName(), 'object_pk' => $this->getOwner()->{$pk}));
return parent::afterDelete($event);
}
开发者ID:kolbensky,项目名称:rybolove,代码行数:11,代码来源:CommentBehavior.php
示例17: beforeValidate
/**
* Actions to take before validating the owner.
* @param CModelEvent $event
*/
public function beforeValidate($event)
{
parent::beforeValidate($event);
if ($this->owner->hasAttribute($this->statusAttribute) && !isset($this->owner->{$this->statusAttribute})) {
$this->owner->{$this->statusAttribute} = $this->defaultStatus;
}
}
开发者ID:crisu83,项目名称:yii-workflow,代码行数:11,代码来源:WorkflowBehavior.php
示例18: __get
public function __get($name)
{
if ($groupName = $this->groupName($name)) {
return $this->getGroupLabels($groupName);
} else {
return parent::__get($name);
}
}
开发者ID:urmaul,项目名称:yii-enumattributes,代码行数:8,代码来源:EnumAttributesBehavior.php
示例19: beforeSave
/**
* @param CModelEvent $event
*/
public function beforeSave($event)
{
if (method_exists($this->getOwner(), 'setDefaultAttributes')) {
$this->getOwner()->setDefaultAttributes();
}
// will the following will be called twice?
return parent::beforeSave($event);
}
开发者ID:cornernote,项目名称:yii-dressing,代码行数:11,代码来源:YdDefaultAttributesBehavior.php
示例20: beforeDelete
/** Will remove associated Gallery before object removal */
public function beforeDelete($event)
{
$gallery = $this->getGallery();
if ($gallery !== null) {
$gallery->delete();
}
parent::beforeDelete($event);
}
开发者ID:hipogea,项目名称:zega,代码行数:9,代码来源:GalleryBehavior.php
注:本文中的CActiveRecordBehavior类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论