AuditableBehavior::afterDelete PHP Method

afterDelete() public method

Executed after a model is deleted.
public afterDelete ( Model $Model ) : void
$Model Model The model that is used for the delete operation.
return void
    public function afterDelete(Model $Model)
    {
        // Do not act on the AuditLog related models.
        if ($this->_isAuditLogModel($Model)) {
            return;
        }
        // If a currentUser() method exists in the model class (or, of
        // course, in a superclass) the call that method to pull all user
        // data. Assume than an ID field exists.
        $source = array();
        if ($Model->hasMethod('currentUser')) {
            $source = $Model->currentUser();
        } elseif ($Model->hasMethod('current_user')) {
            $source = $Model->current_user();
        }
        $audit = array($Model->alias => $this->_original[$Model->alias]);
        $data = array('Audit' => array('event' => 'DELETE', 'model' => $Model->alias, 'entity_id' => $Model->id, 'request_id' => self::_requestId(), 'json_object' => json_encode($audit), 'source_id' => isset($source['id']) ? $source['id'] : null, 'description' => isset($source['description']) ? $source['description'] : null));
        $this->Audit = ClassRegistry::init('AuditLog.Audit');
        $this->Audit->create();
        $this->Audit->save($data);
    }