use yii\db\ActiveRecord; class Post extends ActiveRecord { public $deleted = false; public function beforeDelete() { if ($this->status !== 'published') { $this->deleted = true; return false; //cancel deletion if status is not 'published' } else { $this->deleted = false; return parent::beforeDelete(); } } }In this example, if the `status` field of a `Post` record is not set to 'published', the `$deleted` flag is set to `true` and the `beforeDelete` method returns `false`, causing the deletion to be cancelled. Otherwise, the flag is set to `false` and the parent implementation of `beforeDelete` is called to allow the deletion to proceed as usual. This feature is part of Yii's `ActiveRecord` package library, which is included in the core framework and can be further extended with additional behaviors and components.