baserCMS クラスリファレンス

SoftDeleteTrait

SoftDeleteTrait

Table of Contents

Methods

deleteAll()  : int
Soft deletes all records matching `$conditions`.
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
Query override.
_processDelete()  : bool
Perform the delete operation.

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.

hardDelete()

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()

Query override.

public SelectQuery() : SelectQuery

Fatal error: Declaration of SoftDelete\Model\Table\SoftDeleteTrait::query(): SoftDelete\ORM\Query must be compatible with Cake\ORM\Table::query(): Cake\ORM\Query 上記エラー回避のため戻り値の型宣言では実体と異なるがCakePHP本体のquery()で定義されている上書き元の型(\Cake\ORM\Query)を明示する

Return values
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
throws
InvalidArgumentException

if there are no primary key values of the passed entity

Return values
bool

success


        
On this page

Search results