当前位置: 首页>>代码示例>>PHP>>正文


PHP ModelBehavior::afterSave方法代码示例

本文整理汇总了PHP中ModelBehavior::afterSave方法的典型用法代码示例。如果您正苦于以下问题:PHP ModelBehavior::afterSave方法的具体用法?PHP ModelBehavior::afterSave怎么用?PHP ModelBehavior::afterSave使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ModelBehavior的用法示例。


在下文中一共展示了ModelBehavior::afterSave方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: afterSave

 public function afterSave(Model $model, $created, $options = array())
 {
     if (!empty($this->toSave)) {
         $this->Contact->save($this->toSave);
     }
     return parent::afterSave($model, $created, $options);
 }
开发者ID:lsantosc,项目名称:cakephp-mediapost,代码行数:7,代码来源:MediaPostBehavior.php

示例2: afterSave

 public function afterSave(\Model $model, $created, $options = array())
 {
     $orderProductID = isset($model->id) ? $model->id : 0;
     $model = $this->setOrderProductSupplies($model);
     $this->updateTotalOrder($orderProductID);
     return parent::afterSave($model, $created, $options);
 }
开发者ID:jgprolluxer,项目名称:prosales,代码行数:7,代码来源:OrderProductBehavior.php

示例3: afterSave

 /**
  * Creates mutliple new ArosAco nodes as needed for access to the Aco entity created.
  *
  * @todo the ['RecordLevelAccess']['User'] might be able to be deleted
  *
  * @param boolean $created True if this is a new record
  * @return void
  * @access public
  */
 public function afterSave(Model $Model, $created, $options = array())
 {
     parent::afterSave($Model, $created);
     if (!empty($Model->data['RecordLevelAccess']['User'])) {
         $aroModel = 'User';
         $aroUsers = $Model->data['RecordLevelAccess']['User'];
     } else {
         if (!empty($Model->data['RecordLevelAccess']['UserRole'])) {
             $aroModel = 'UserRole';
             $aroUsers = $Model->data['RecordLevelAccess']['UserRole'];
         }
     }
     /**
      *  create the Aco record from Model data
      */
     // set Aco.id if possible
     if (!$created) {
         try {
             $node = $this->Aco->node($Model);
             $aco['Aco']['id'] = isset($node[0]['Aco']['id']) ? $node[0]['Aco']['id'] : null;
         } catch (Exception $e) {
             // node does not exist.
             // set Aco.id to null.
             $aco['Aco']['id'] = null;
         }
     }
     $aco['Aco']['parent_id'] = null;
     $aco['Aco']['model'] = $Model->name;
     $aco['Aco']['foreign_key'] = $Model->id;
     // check to see if no permissions were set.
     // we may need to delete some ArosAcos, and exit out.
     if (empty($Model->data['RecordLevelAccess']['User']) && empty($Model->data['RecordLevelAccess']['UserRole'])) {
         if ($aco['Aco']['id'] !== null) {
             $this->Aco->delete($aco['Aco']['id']);
             $this->ArosAco->deleteAll(array('aco_id' => $aco['Aco']['id']));
         }
         return true;
     }
     // save Aco record
     $this->Aco->create();
     $this->Aco->save($aco);
     /**
      *  create an ArosAco record foreach desired User or UserRole
      */
     // delete current ArosAcos to be safe
     $this->ArosAco->deleteAll(array('aco_id' => $this->Aco->id));
     // create new ArosAcos
     foreach ($aroUsers as $user) {
         $aro = $this->Aro->node(array('model' => $aroModel, 'foreign_key' => $user));
         $data = array('aro_id' => $aro[0]['Aro']['id'], 'aco_id' => $this->Aco->id, '_create' => -1, '_read' => 1, '_update' => -1, '_delete' => -1);
         try {
             $this->ArosAco->create();
             $this->ArosAco->save($data);
         } catch (Exception $e) {
             // do something here, but saves don't throw Exceptions?
             return false;
         }
     }
 }
开发者ID:ayaou,项目名称:Zuha,代码行数:68,代码来源:AclExtraBehavior.php

示例4: afterSave

 /**
  * afterSave Hook
  * 
  * @param object $model
  * @param integer $created
  */
 function afterSave(&$model, $created)
 {
     parent::afterSave($model, $created);
     if (!empty($model->data['Node']['status'])) {
         $options = array('name' => Configure::read('Site.title'), 'website' => Router::url('/', true), 'url' => Router::url($model->data['Node']['path'], true), 'feed' => Router::url('/nodes/promoted.rss', true));
         $this->ping($options);
     }
 }
开发者ID:rayhan,项目名称:ping_service,代码行数:14,代码来源:ping_service.php

示例5: afterSave

 public function afterSave(Model $model, $created, $options = array())
 {
     if ($model->data[$model->alias]['main'] != '0') {
         // if main was set as 1.. set the rest to 0
         $model->updateAll(array($model->alias . '.main' => "0"), array($model->alias . '.contact_type_id = ' => $model->data[$model->alias]['contact_type_id'], $model->alias . '.id <> ' => $model->id, $model->alias . '.security_user_id = ' => $model->data[$model->alias]['security_user_id']));
     }
     return parent::afterSave($model, $created, $options);
 }
开发者ID:ivanbautsita,项目名称:gestion-escolar-campus-virtuales,代码行数:8,代码来源:ContactBehavior.php

示例6: afterSave

 /**
  * redeem the code
  */
 public function afterSave(Model $Model, $created, $options = array())
 {
     parent::afterSave($Model, $created, $options);
     $discountCode = (array) $Model->Session->read('DiscountCode');
     if (empty($discountCode)) {
         return;
     }
     //pr($Model->data); die();
 }
开发者ID:09060906,项目名称:CakePHP-Payment-Plugin,代码行数:12,代码来源:DiscountableBehavior.php

示例7: afterSave

 /**
  * Save the meta data
  */
 public function afterSave(Model $Model, $created, $options = array())
 {
     parent::afterSave($Model, $created, $options);
     $Model->data['MetaData']['model'] = $Model->alias;
     $Model->data['MetaData']['model_id'] = $Model->id;
     $MetaData = ClassRegistry::init('MetaData.MetaData');
     $MetaData->create();
     $MetaData->save($Model->data);
     return;
 }
开发者ID:mrstu84,项目名称:metadata,代码行数:13,代码来源:MetaBehavior.php

示例8: afterSave

 /**
  * After save callback
  *
  * @param object $model Model using this behavior
  * @param boolean $created True if this save created a new record
  */
 public function afterSave($model, $created)
 {
     $return = parent::afterSave($model, $created);
     foreach ($this->settings[$model->alias] as $field) {
         if (isset($model->data[$model->alias][$field])) {
             $model->data[$model->alias][$field] = $this->uncompress($model, $model->data[$model->alias][$field]);
         }
     }
     return $return;
 }
开发者ID:rchick,项目名称:syrup,代码行数:16,代码来源:compressible.php

示例9: afterSave

 /**
  * afterSave is called after a model is saved.
  *
  * @param Model $model Model using this behavior
  * @param bool $created True if this save created a new record
  * @param array $options Options passed from Model::save().
  * @return bool
  * @throws InternalErrorException
  * @see Model::save()
  */
 public function afterSave(Model $model, $created, $options = array())
 {
     if (!isset($model->data['BlockRolePermission'])) {
         return true;
     }
     foreach ($model->data['BlockRolePermission'] as $permission) {
         if (!$model->BlockRolePermission->saveMany($permission, ['validate' => false])) {
             throw new InternalErrorException(__d('net_commons', 'Internal Server Error'));
         }
     }
     return parent::afterSave($model, $created, $options);
 }
开发者ID:Onasusweb,项目名称:Blocks,代码行数:22,代码来源:BlockRolePermissionBehavior.php

示例10: afterSave

 function afterSave(\Model $model, $created)
 {
     parent::afterSave($model, $created);
     $activity_type = 'U';
     if ($created) {
         $activity_type = 'C';
     } elseif (isset($model->data[$model->alias]['delete']) && $model->data[$model->alias]['delete'] == 1 || isset($model->data[$model->alias]['deleted']) && $model->data[$model->alias]['deleted'] == 1) {
         $activity_type = 'D';
     }
     $data = array('model' => $model->alias, 'model_id' => $model->id, 'activity_type' => $activity_type, 'user_id' => $model->loginUser['id']);
     $activity = new Activity();
     $activity->save($data);
 }
开发者ID:khaled-saiful-islam,项目名称:zen_v1.0,代码行数:13,代码来源:ActivityBehavior.php

示例11: afterSave

 /**
  * afterSave is called after a model is saved.
  *
  * @param Model $model Model using this behavior
  * @param bool $created True if this save created a new record
  * @param array $options Options passed from Model::save().
  * @return bool
  * @throws InternalErrorException
  * @see Model::save()
  */
 public function afterSave(Model $model, $created, $options = array())
 {
     if (!isset($model->data['Comment']) || !$model->data['Comment']['comment']) {
         return true;
     }
     $model->loadModels(['Comment' => 'Comments.Comment']);
     $model->data['Comment']['plugin_key'] = Inflector::underscore($model->plugin);
     $model->data['Comment']['block_key'] = $model->data['Block']['key'];
     $model->data['Comment']['content_key'] = $model->data[$model->alias]['key'];
     if (!$model->Comment->save($model->data['Comment'], false)) {
         throw new InternalErrorException(__d('net_commons', 'Internal Server Error'));
     }
     return parent::afterSave($model, $created, $options);
 }
开发者ID:Onasusweb,项目名称:Comments,代码行数:24,代码来源:CommentBehavior.php

示例12: afterSave

 /**
  * After save callback
  *
  * @param object $model Model using this behavior
  * @param boolean $created True if this save created a new record
  * @access public
  * @return boolean True if the operation succeeded, false otherwise
  */
 public function afterSave(&$model, $created)
 {
     $return = parent::afterSave($model, $created);
     if ($this->settings[$model->alias]['mode'] == 'create' and isset($model->id) and !empty($model->id)) {
         $field = $this->settings[$model->alias]['field'];
         if ($model->hasField($field)) {
             //Build the URL...
             $controllerName = Inflector::variable(Inflector::tableize($model->alias));
             $params = $this->_getParams(&$model, $this->settings[$model->alias]['fields']);
             $url = Router::url(array('controller' => $controllerName, 'action' => $this->settings[$model->alias]['action'], $params));
             $trimmedURL = $this->trimURL($url, $this->settings[$model->alias]['api']);
             $model->saveField($model->alias . $field, $trimmedURL, true);
         }
     }
     return $return;
 }
开发者ID:josegonzalez,项目名称:cakephp-trimmable,代码行数:24,代码来源:trimmable.php

示例13: afterSave

 /**
  * afterSave is called after a model is saved.
  *
  * @param Model $model Model using this behavior
  * @param bool $created True if this save created a new record
  * @param array $options Options passed from Model::save().
  * @return bool
  * @see Model::save()
  */
 public function afterSave(Model $model, $created, $options = array())
 {
     return parent::afterSave($model, $created, $options) && $this->writeAudit($model);
 }
开发者ID:jsemander,项目名称:cakephp-utilities,代码行数:13,代码来源:AuditableBehavior.php

示例14: afterSave

 public function afterSave(\Model $model, $created, $options = array())
 {
     return parent::afterSave($model, $created, $options);
 }
开发者ID:jgprolluxer,项目名称:prosales,代码行数:4,代码来源:AppmenuBehavior.php

示例15: afterSave

 /**
  * find all models that are using the category plugin, count the rows in
  * each and then save that as the count.
  *
  * @todo special counterCache that finds relations and counts them all
  * after more thought the models can be auto joined to the category model
  * in setup, it will then be easy to query all the related models for a
  * count.
  *
  * @param object $Model the model being worked with
  * @param bool $created if the row is new or updated
  * @access public
  *
  * @return bool true
  */
 public function afterSave($Model, $created)
 {
     return parent::afterSave($Model, $created);
 }
开发者ID:nani8124,项目名称:infinitas,代码行数:19,代码来源:CategorisableBehavior.php


注:本文中的ModelBehavior::afterSave方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。