models/News.php
protected function deleteFiles($id)
    {//echo __METHOD__."($id)";
        $subdir = static::getImageSubdir($id);
        if (!empty($this->module->params['uploadsNewsDir'])) {
            $uploadsDir = Yii::getAlias($this->module->params['uploadsNewsDir']) . '/' . $subdir;//var_dump($uploadsDir);
            //@FileHelper::removeDirectory($uploadsDir);
            rename($uploadsDir, $uploadsDir . '~remove~' . date('ymd~His') . '~');
        }
        if (array_key_exists('@webfilespath', Yii::$aliases) && !empty($this->module->params['filesSubpath'])) {
            $webfilesDir = Yii::getAlias('@webfilespath') . '/' . $this->module->params['filesSubpath'] . '/' . $subdir;//var_dump($webfilesDir);
            @FileHelper::removeDirectory($webfilesDir);
        }
        //?! Yii2-advanced temblate has 2 web roots. Here delete only one.
    }
protected function deleteFiles($id)
    {//echo __METHOD__."($id)";
        $subdir = static::getImageSubdir($id);
        if (!empty($this->module->params['uploadsNewsDir'])) {
            $uploadsDir = Yii::getAlias($this->module->params['uploadsNewsDir']) . '/' . $subdir;//var_dump($uploadsDir);
            //@FileHelper::removeDirectory($uploadsDir);
            rename($uploadsDir, $uploadsDir . '~remove~' . date('ymd~His') . '~');
        }
        if (array_key_exists('@webfilespath', Yii::$aliases) && !empty($this->module->params['filesSubpath'])) {
            $webfilesDir = Yii::getAlias('@webfilespath') . '/' . $this->module->params['filesSubpath'] . '/' . $subdir;//var_dump($webfilesDir);
            @FileHelper::removeDirectory($webfilesDir);
        }
        //?! Yii2-advanced temblate has 2 web roots. Here delete only one.
    }
protected function deleteFiles ( $ id ) { //echo __METHOD__."($id)"; $ subdir = static :: getImageSubdir ( $ id ) ; if ( ! empty ( $ this -> module -> params [ 'uploadsNewsDir' ] ) ) { $ uploadsDir = Yii :: getAlias ( $ this -> module -> params [ 'uploadsNewsDir' ] ) . '/' . $ subdir ; //var_dump($uploadsDir); //@FileHelper::removeDirectory($uploadsDir); rename ( $ uploadsDir , $ uploadsDir . '~remove~' . date ( 'ymd~His' ) . '~' ) ; } if ( array_key_exists ( '@webfilespath' , Yii :: $ aliases ) && ! empty ( $ this -> module -> params [ 'filesSubpath' ] ) ) { $ webfilesDir = Yii :: getAlias ( '@webfilespath' ) . '/' . $ this -> module -> params [ 'filesSubpath' ] . '/' . $ subdir ; //var_dump($webfilesDir); @ FileHelper :: removeDirectory ( $ webfilesDir ) ; } //?! Yii2-advanced temblate has 2 web roots. Here delete only one. }
Delete uploaded files connected with the model.
@param integet $id model id
Delete uploaded files connected with the model .