PHP Trait SoftDelete\Model\Table\SoftDeleteTrait

Show file Open project: pgbi/cakephp3-soft-delete

Public Methods

Method Description
deleteAll ( $conditions ) : integer Soft deletes all records matching $conditions.
getSoftDeleteField ( ) : string Get the configured deletion field
hardDelete ( Cake\Datasource\EntityInterface $entity ) : boolean Hard deletes the given $entity.
hardDeleteAll ( Datetime $until ) : integer Hard deletes all records that were soft deleted before a given date.
query ( )
restore ( Cake\Datasource\EntityInterface $entity ) : boolean Restore a soft deleted entity into an active state.

Protected Methods

Method Description
_processDelete ( Cake\DataSource\EntityInterface $entity, ArrayObject $options ) : boolean Perform the delete operation.

Method Details

_processDelete() protected method

Will soft delete the entity provided. Will remove rows from any dependent associations, and clear out join tables for BelongsToMany associations.
protected _processDelete ( Cake\DataSource\EntityInterface $entity, ArrayObject $options ) : boolean
$entity Cake\DataSource\EntityInterface The entity to soft delete.
$options ArrayObject The options for the delete.
return boolean success

deleteAll() public method

Soft deletes all records matching $conditions.
public deleteAll ( $conditions ) : integer
return integer number of affected rows.

getSoftDeleteField() public method

Get the configured deletion field
public getSoftDeleteField ( ) : string
return string

hardDelete() public method

Hard deletes the given $entity.
public hardDelete ( Cake\Datasource\EntityInterface $entity ) : boolean
$entity Cake\Datasource\EntityInterface
return boolean true in case of success, false otherwise.

hardDeleteAll() public method

Hard deletes all records that were soft deleted before a given date.
public hardDeleteAll ( Datetime $until ) : integer
$until Datetime Date until which soft deleted records must be hard deleted.
return integer number of affected rows.

query() public method

public query ( )

restore() public method

Restore a soft deleted entity into an active state.
public restore ( Cake\Datasource\EntityInterface $entity ) : boolean
$entity Cake\Datasource\EntityInterface Entity to be restored.
return boolean true in case of success, false otherwise.