public function beforeDelete($event)
 {
     $model = $this->getOwner();
     if (method_exists($model, "uploadFiles")) {
         $files = $model->uploadFiles();
         foreach ($files as $attr => $params) {
             if (!$model->{$attr}) {
                 continue;
             }
             $dir = $params["dir"];
             if (substr($dir, 0, strlen($_SERVER['DOCUMENT_ROOT'])) != $_SERVER['DOCUMENT_ROOT']) {
                 $dir = $_SERVER['DOCUMENT_ROOT'] . $dir;
             }
             if (substr($dir, -1) != '/') {
                 $dir .= '/';
             }
             FileSystemHelper::deleteFileWithSimilarNames($dir, $model->{$attr});
         }
     }
 }
 private function _save($options)
 {
     $model = ActiveRecord::model($options['model'])->findByPk($options['id']);
     //may be you will be need set some attributes before update
     if (isset($options['attributes'])) {
         $model->attributes = $options['attributes'];
     }
     $attribute = $options['attribute'];
     $model->{$attribute} = $options['value'];
     if ($model->saveAttributes(array($attribute))) {
         if (isset($options['unlink_file'])) {
             $file = Yii::getPathOfAlias('webroot') . '/' . $options['unlink_file'];
             if (is_file($file) && FileSystemHelper::isAllowForUnlink($file)) {
                 FileSystemHelper::deleteFileWithSimilarNames(pathinfo($file, PATHINFO_DIRNAME), pathinfo($file, PATHINFO_BASENAME));
             }
         }
         echo $model->{$attribute};
     } else {
         echo $model->getError($attribute);
     }
 }