Class lispa\amos\core\behaviors\SoftDeleteByBehavior
Inheritance | lispa\amos\core\behaviors\SoftDeleteByBehavior » yii\base\Behavior » yii\base\Object |
---|---|
Implements | yii\base\Configurable |
Class SoftDeleteByBehavior
Public Properties
Property | Type | Description | Defined By |
---|---|---|---|
$deletedAtAttribute | lispa\amos\core\behaviors\SoftDeleteByBehavior | ||
$deletedByAttribute | lispa\amos\core\behaviors\SoftDeleteByBehavior | ||
$owner | yii\base\Component|null | The owner of this behavior | yii\base\Behavior |
$safeMode | boolean | If true, this behavior will process '$model->delete()' as a soft-delete. | lispa\amos\core\behaviors\SoftDeleteByBehavior |
$timestamp | lispa\amos\core\behaviors\SoftDeleteByBehavior |
Public Methods
Method | Description | Defined 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
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()'
Method Details
Set the attribute with the current timestamp to mark as deleted
public boolean|void doDeleteTimestamp ( $event ) | ||
$event | yii\base\Event |
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). |
---|
Delete record from database regardless of the $safeMode attribute
public void forceDelete ( ) |
Remove (aka soft-delete) record
public void remove ( ) |
Restore soft-deleted record
public void restore ( ) |