src/apis/StorageController.php
public function actionFolderDelete($folderId)
    {
        $this->checkRouteAccess(self::PERMISSION_ROUTE);
        
        // find all subfolders
        $matchingChildFolders = StorageFolder::find()->where(['parent_id' => $folderId])->asArray()->all();
        foreach ($matchingChildFolders as $matchingChildFolder) {
            $this->actionFolderDelete($matchingChildFolder['id']);
        }
        
        // find all attached files and delete them
        $folderFiles = StorageFile::find()->where(['folder_id' => $folderId])->all();
        foreach ($folderFiles as $folderFile) {
            $folderFile->delete();
        }
        
        // delete folder
        $model = StorageFolder::findOne($folderId);
        if (!$model) {
            return false;
        }
        $model->is_deleted = true;
        
        $this->flushApiCache();
        
        return $model->update();
    }
public function actionFolderDelete($folderId)
    {
        $this->checkRouteAccess(self::PERMISSION_ROUTE);
        
        // find all subfolders
        $matchingChildFolders = StorageFolder::find()->where(['parent_id' => $folderId])->asArray()->all();
        foreach ($matchingChildFolders as $matchingChildFolder) {
            $this->actionFolderDelete($matchingChildFolder['id']);
        }
        
        // find all attached files and delete them
        $folderFiles = StorageFile::find()->where(['folder_id' => $folderId])->all();
        foreach ($folderFiles as $folderFile) {
            $folderFile->delete();
        }
        
        // delete folder
        $model = StorageFolder::findOne($folderId);
        if (!$model) {
            return false;
        }
        $model->is_deleted = true;
        
        $this->flushApiCache();
        
        return $model->update();
    }
public function actionFolderDelete ( $ folderId ) { $ this -> checkRouteAccess ( self :: PERMISSION_ROUTE ) ; // find all subfolders $ matchingChildFolders = StorageFolder :: find ( ) -> where ( [ 'parent_id' => $ folderId ] ) -> asArray ( ) -> all ( ) ; foreach ( $ matchingChildFolders as $ matchingChildFolder ) { $ this -> actionFolderDelete ( $ matchingChildFolder [ 'id' ] ) ; } // find all attached files and delete them $ folderFiles = StorageFile :: find ( ) -> where ( [ 'folder_id' => $ folderId ] ) -> all ( ) ; foreach ( $ folderFiles as $ folderFile ) { $ folderFile -> delete ( ) ; } // delete folder $ model = StorageFolder :: findOne ( $ folderId ) ; if ( ! $ model ) { return false ; } $ model -> is_deleted = true ; $ this -> flushApiCache ( ) ; return $ model -> update ( ) ; }
delete folder, all subfolders and all included files.

1. search another folders with matching parentIds and call deleteFolder on them
2. get all included files and delete them
3. delete folder

@param integer $folderId The folder to delete.
@todo move to storage helpers?
@return boolean
delete folder all subfolders and all included files .