SoftDeleteTrait
SoftDeleteTrait
Table of Contents
Properties
- $enabled : bool
- 利用状態
Methods
- deleteAll() : int
- Soft deletes all records matching `$conditions`.
- disableSoftDelete() : void
- 論理削除を利用不可にする
- enableSoftDelete() : void
- 論理削除を利用可能にする
- getSoftDeleteField() : string
- Get the configured deletion field
- hardDelete() : bool
- Hard deletes the given $entity.
- hardDeleteAll() : int
- Hard deletes all records that were soft deleted before a given date.
- restore() : bool
- Restore a soft deleted entity into an active state.
- SelectQuery() : SelectQuery|SelectQuery
- Select Query
- _processDelete() : bool
- Perform the delete operation.
Properties
$enabled
利用状態
private
bool
$enabled
= true
Methods
deleteAll()
Soft deletes all records matching `$conditions`.
public
deleteAll(array<string|int, mixed> $conditions) : int
Parameters
- $conditions : array<string|int, mixed>
-
entities search conditions
Return values
int —number of affected rows.
disableSoftDelete()
論理削除を利用不可にする
public
disableSoftDelete() : void
enableSoftDelete()
論理削除を利用可能にする
public
enableSoftDelete() : void
getSoftDeleteField()
Get the configured deletion field
public
getSoftDeleteField() : string
Tags
Return values
stringhardDelete()
Hard deletes the given $entity.
public
hardDelete(EntityInterface $entity) : bool
Parameters
- $entity : EntityInterface
-
entity
Return values
bool —true in case of success, false otherwise.
hardDeleteAll()
Hard deletes all records that were soft deleted before a given date.
public
hardDeleteAll(DateTime $until) : int
Parameters
- $until : DateTime
-
Date until which soft deleted records must be hard deleted.
Return values
int —number of affected rows.
restore()
Restore a soft deleted entity into an active state.
public
restore(EntityInterface $entity) : bool
Parameters
- $entity : EntityInterface
-
Entity to be restored.
Return values
bool —true in case of success, false otherwise.
SelectQuery()
Select Query
public
SelectQuery() : SelectQuery|SelectQuery
論理削除用の SelectQuery を返却する TreeBehavior を利用して、アイテムを移動する場合、 論理削除されたアイテムも対象としなければツリー構造が壊れてしまうため、 SoftDeleteTrait を、利用不可にすることで、オリジナルの SelectQueryを返却できるようにしている
Return values
SelectQuery|SelectQuery_processDelete()
Perform the delete operation.
protected
_processDelete(EntityInterface $entity, ArrayObject $options) : bool
Will soft delete the entity provided. Will remove rows from any dependent associations, and clear out join tables for BelongsToMany associations.
Parameters
- $entity : EntityInterface
-
The entity to soft delete.
- $options : ArrayObject
-
The options for the delete.
Tags
Return values
bool —success