Свойство | Type | Description | |
---|---|---|---|
$allowDeleteCallback | callback, which execution determines if record should be "hard" deleted instead of being marked as deleted. Callback should match following signature: boolean function(BaseActiveRecord $model) For example: php function ($user) { return $user->lastLoginDate === null; } | ||
$deleteFallbackException | class name of the exception, which should trigger a fallback to SoftDeleteBehavior::softDelete method from SoftDeleteBehavior::safeDelete. By default [[\yii\db\IntegrityException]] is used, which means soft deleting will be performed on foreign constraint violation DB exception. You may specify another exception class here to customize fallback error level. For example: usage of [[\Exception]] will cause soft-delete fallback on any error during regular deleting. | ||
$invokeDeleteEvents | whether to invoke owner [[BaseActiveRecord::beforeDelete()]] and [[BaseActiveRecord::afterDelete()]] while performing soft delete. This option affects only SoftDeleteBehavior::softDelete method. | ||
$restoreAttributeValues | values of the owner attributes, which should be applied on restoration from "deleted" state, in format: [attributeName => attributeValue]. If not set value will be automatically detected from [[softDeleteAttributeValues]]. | ||
$softDeleteAttributeValues | values of the owner attributes, which should be applied on soft delete, in format: [attributeName => attributeValue]. Those may raise a flag: php ['isDeleted' => true] or switch status: php ['statusId' => Item::STATUS_DELETED] Attribute value can be a callable: php ['isDeleted' => function ($model) {return time()}] |
Méthode | Description | |
---|---|---|
afterRestore ( ) | This method is invoked after record is restored from "deleted" state. | |
afterSoftDelete ( ) | This method is invoked after soft deleting a record. | |
beforeDelete ( |
Handles owner 'beforeDelete' owner event, applying soft delete and preventing actual deleting. | |
beforeRestore ( ) : boolean | This method is invoked before record is restored from "deleted" state. | |
beforeSoftDelete ( ) : boolean | This method is invoked before soft deleting a record. | |
events ( ) | ||
getReplaceRegularDelete ( ) : boolean | ||
restore ( ) : integer | false | Restores record from "deleted" state, after it has been "soft" deleted. | |
safeDelete ( ) : false | integer | Attempts to perform regular [[BaseActiveRecord::delete()]], if it fails with exception, falls back to SoftDeleteBehavior::softDelete. | |
setReplaceRegularDelete ( boolean $replaceRegularDelete ) | ||
softDelete ( ) : integer | false | Marks the owner as deleted. |
Méthode | Description | |
---|---|---|
isDeleteAllowed ( ) : boolean | ||
restoreInternal ( ) : integer | ||
softDeleteInternal ( ) : integer | false | Marks the owner as deleted. |
Méthode | Description | |
---|---|---|
beginTransaction ( ) : |
Begins new database transaction if owner allows it. |
public afterRestore ( ) |
public afterSoftDelete ( ) |
public beforeDelete ( |
||
$event | event instance. |
public beforeRestore ( ) : boolean | ||
Résultat | boolean | whether the record should be restored. Defaults to true. |
public beforeSoftDelete ( ) : boolean | ||
Résultat | boolean | whether the record should be deleted. Defaults to true. |
public getReplaceRegularDelete ( ) : boolean | ||
Résultat | boolean |
protected isDeleteAllowed ( ) : boolean | ||
Résultat | boolean | whether owner "hard" deletion allowed or not. |
protected restoreInternal ( ) : integer | ||
Résultat | integer | the number of restored rows. |
public safeDelete ( ) : false | integer | ||
Résultat | false | integer | number of affected rows. |
public setReplaceRegularDelete ( boolean $replaceRegularDelete ) | ||
$replaceRegularDelete | boolean |
public softDelete ( ) : integer | false | ||
Résultat | integer | false | the number of rows marked as deleted, or false if the soft deletion is unsuccessful for some reason. Note that it is possible the number of rows deleted is 0, even though the soft deletion execution is successful. |
protected softDeleteInternal ( ) : integer | false | ||
Résultat | integer | false | the number of rows marked as deleted, or false if the soft deletion is unsuccessful for some reason. |
public $allowDeleteCallback |
public $deleteFallbackException |
public $invokeDeleteEvents |
public $restoreAttributeValues |
public $softDeleteAttributeValues |