Class lispa\amos\core\behaviors\SoftDeleteByBehavior

Inheritancelispa\amos\core\behaviors\SoftDeleteByBehavior » yii\base\Behavior » yii\base\Object
Implementsyii\base\Configurable

Class SoftDeleteByBehavior

Public Methods

Hide inherited methods

MethodDescriptionDefined By
__call() Calls the named method which is not a class method. yii\base\Object
__construct() Constructor. yii\base\Object
__get() Returns the value of an object property. yii\base\Object
__isset() Checks if a property is set, i.e. defined and not null. yii\base\Object
__set() Sets value of an object property. yii\base\Object
__unset() Sets an object property to null. yii\base\Object
attach() Attaches the behavior object to the component. yii\base\Behavior
canGetProperty() Returns a value indicating whether a property can be read. yii\base\Object
canSetProperty() Returns a value indicating whether a property can be set. yii\base\Object
className() Returns the fully qualified name of this class. yii\base\Object
detach() Detaches the behavior object from the component. yii\base\Behavior
doDeleteTimestamp() Set the attribute with the current timestamp to mark as deleted lispa\amos\core\behaviors\SoftDeleteByBehavior
events() Declares event handlers for the $owner's events. lispa\amos\core\behaviors\SoftDeleteByBehavior
forceDelete() Delete record from database regardless of the $safeMode attribute lispa\amos\core\behaviors\SoftDeleteByBehavior
hasMethod() Returns a value indicating whether a method is defined. yii\base\Object
hasProperty() Returns a value indicating whether a property is defined. yii\base\Object
init() Initializes the object. yii\base\Object
remove() Remove (aka soft-delete) record lispa\amos\core\behaviors\SoftDeleteByBehavior
restore() Restore soft-deleted record lispa\amos\core\behaviors\SoftDeleteByBehavior

Property Details

$deletedAtAttribute public property
public $deletedAtAttribute 'deleted_at'
$deletedByAttribute public property
public $deletedByAttribute 'deleted_by'
$safeMode public property

If true, this behavior will process '$model->delete()' as a soft-delete. Thus, the

      only way to truely delete a record is to call '$model->forceDelete()'
public boolean $safeMode true
$timestamp public property
public $timestamp null

Method Details

doDeleteTimestamp() public method

Set the attribute with the current timestamp to mark as deleted

public boolean|void doDeleteTimestamp ( $event )
$event yii\base\Event
events() public method

Declares event handlers for the $owner's events.

Child classes may override this method to declare what PHP callbacks should be attached to the events of the $owner component.

The callbacks will be attached to the $owner's events when the behavior is attached to the owner; and they will be detached from the events when the behavior is detached from the component.

The callbacks can be any of the following:

  • method in this behavior: 'handleClick', equivalent to [$this, 'handleClick']
  • object method: [$object, 'handleClick']
  • static method: ['Page', 'handleClick']
  • anonymous function: function ($event) { ... }

The following is an example:

[
    Model::EVENT_BEFORE_VALIDATE => 'myBeforeValidate',
    Model::EVENT_AFTER_VALIDATE => 'myAfterValidate',
]
public array events ( )
return array

Events (array keys) and the corresponding event handler methods (array values).

forceDelete() public method

Delete record from database regardless of the $safeMode attribute

public void forceDelete ( )
remove() public method

Remove (aka soft-delete) record

public void remove ( )
restore() public method

Restore soft-deleted record

public void restore ( )