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


PHP ModelBehavior::beforeDelete方法代码示例

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


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

示例1: beforeDelete

 /**
  * Before delete is called before any delete occurs on the attached model, but after the model's
  * beforeDelete is called. Returning false from a beforeDelete will abort the delete.
  *
  * @param Model $model Model using this behavior
  * @param bool $cascade If true records that depend on this record will also be deleted
  * @return mixed False if the operation should abort. Any other result will continue.
  */
 public function beforeDelete(Model $model, $cascade = true)
 {
     if (!empty($model->hasMany['Audit'])) {
         if ($model->id = !empty($model->id) ? $model->id : (!empty($model->data[$model->alias]['id']) ? $model->data[$model->alias]['id'] : '')) {
             $record = $model->read(null);
             $this->data[$model->id]['Audit']['entity'] = (!empty($model->plugin) ? $model->plugin . '.' : '') . $model->name;
             $this->data[$model->id]['Audit']['entity_id'] = $model->id;
             $this->data[$model->id]['Audit']['event'] = 'DELETE';
             $this->data[$model->id]['Audit']['old'] = json_encode($record[$model->alias]);
             $this->data[$model->id]['Audit']['new'] = json_encode(array());
             $this->data[$model->id]['Audit']['creator_id'] = !empty($model->data['Creator']['id']) ? $model->data['Creator']['id'] : null;
             $model->data = Hash::remove($model->data, 'Creator');
         }
     }
     return parent::beforeDelete($model, $cascade);
 }
开发者ID:jsemander,项目名称:cakephp-utilities,代码行数:24,代码来源:AuditableBehavior.php

示例2: beforeDelete

 /**
  * Before delete callback
  *
  * @param object $model
  * @return void
  */
 public function beforeDelete(Model $model, $cascade = true)
 {
     parent::beforeDelete($model, $cascade);
     $model->bindModel(array('hasMany' => array('Nodeattachment' => array('order' => array('Nodeattachment.priority ASC', 'Nodeattachment.created ASC')))));
     $data = $model->findById($model->id);
     if (isset($data['Nodeattachment'])) {
         App::import('Model', 'Nodeattachment.Nodeattachment');
         $Nodeattachment = new Nodeattachment();
         // delete all attachments for node
         foreach ($data['Nodeattachment'] as $attachment) {
             $Nodeattachment->read(null, $attachment['id']);
             if (!$Nodeattachment->delete($attachment['id'])) {
                 return FALSE;
             }
         }
     }
     return true;
 }
开发者ID:elcuro,项目名称:nodeattachment,代码行数:24,代码来源:NodeattachmentBehavior.php

示例3: beforeDelete

 /**
  * beforeDelete method
  *
  * @param Model $model
  * @param boolean $cascade
  * @return void
  */
 public function beforeDelete(Model $model, $cascade = true)
 {
     $settings = $this->settings[$model->alias];
     if (!isset($settings['beforeDelete']) || $settings['beforeDelete'] === 'off') {
         return parent::beforeDelete($model, $cascade);
     }
     switch ($settings['beforeDelete']) {
         case 'on':
             return false;
         case 'test':
             return null;
         case 'test2':
             echo 'beforeDelete success';
             if ($cascade) {
                 echo ' (cascading) ';
             }
             return true;
     }
 }
开发者ID:magooemp,项目名称:eramba,代码行数:26,代码来源:BehaviorCollectionTest.php

示例4: beforeDelete

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

示例5: beforeDelete

 /**
  * Called before every deletion operation.
  *
  * @param Model $model Model instance
  * @param boolean $cascade If true records that depend on this record will also be deleted
  * @return boolean True if the operation should continue, false if it should abort
  */
 public function beforeDelete(Model $model, $cascade = true)
 {
     $data = $model->find('first', array('conditions' => array("{$model->alias}.{$model->primaryKey}" => $model->id), 'contain' => false, 'recursive' => -1));
     foreach ($this->settings[$model->alias] as $field => $options) {
         $this->_prepareFilesForDeletion($model, $field, $data, $options);
     }
     return parent::beforeDelete($model, $cascade);
 }
开发者ID:hotanlam,项目名称:japansource,代码行数:15,代码来源:UploadBehavior.php

示例6: beforeDelete

 public function beforeDelete(\Model $model, $cascade = true)
 {
     parent::beforeDelete($model);
     return true;
 }
开发者ID:pdkhuong,项目名称:BBG,代码行数:5,代码来源:MultiLanguageBehavior.php

示例7: beforeDelete

 /**
  * Catch the request to delete and route to our own delete method
  * 
  * // TODO: Try and remove this, as the controller should be calling the delete
  * method in the model, which this should overwrite
  * 
  * // TODO: Think about the return here as returning true will continue the
  * delete and will probably be destructive
  * 
  * @param Model $model
  * @param bool $cascade
  * @return bool
  */
 public function beforeDelete(Model $model, $cascade = true)
 {
     parent::beforeDelete($model, $cascade);
     $this->delete($model, $model->data[$model->alias]['id'], $cascade);
     return false;
 }
开发者ID:Adnan0703,项目名称:CakePHP-Statusable,代码行数:19,代码来源:StatusableBehavior.php

示例8: beforeDelete

 /**
  *
  *
  * @param Model $Model
  * @param bool $cascade
  */
 public function beforeDelete(Model $Model, $cascade = true)
 {
     parent::beforeDelete($Model, $cascade);
     $this->takeSnapshot($Model);
     return true;
 }
开发者ID:radig,项目名称:auditable,代码行数:12,代码来源:AuditableBehavior.php

示例9: beforeDelete

 /**
  * Called automatically before Model::delete()
  *
  * If deleting a record that has associated habtm records, the habtm records
  * counter caches will need re-calculating, so identify them. E.g. get the
  * tag_ids of the Tags that the Post being deleted was tagged with.
  *
  * @param AppModel $model
  * @return boolean Always true
  */
 public function beforeDelete(\Model $model, $cascade = true)
 {
     parent::beforeDelete($model, $cascade);
     $this->_setOldHabtmIds($model);
     return true;
 }
开发者ID:hurad,项目名称:hurad,代码行数:16,代码来源:HabtmCounterCacheBehavior.php

示例10: beforeDelete

 /**
  * beforeDelete callback
  *
  * cleanup any related bitmask rows
  *
  * @param	Model	$Model
  * @param	boolean	$cascade
  * @return	mixed
  */
 public function beforeDelete(Model $Model, $cascade = true)
 {
     if ($this->settings[$Model->alias]['consolidated'] && !$this->settings[$Model->alias]['disabled'] && $cascade && !$Model->Behaviors->loaded('SoftDeletable')) {
         $this->_bind($Model);
     } else {
         $this->_unbind($Model);
     }
     return parent::beforeDelete($Model, $cascade);
 }
开发者ID:jmcneese,项目名称:bitmasked,代码行数:18,代码来源:BitmaskedBehavior.php


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