modxcms / revolution

MODX Revolution - Content Management Framework
https://modx.com/
GNU General Public License v2.0
1.36k stars 529 forks source link

Give the ability to interrupt the file uploading on OnFileManagerBeforeUpload event #14151

Closed GulomovCreative closed 5 years ago

GulomovCreative commented 5 years ago

Summary

We have a plugin that should fired the "OnFileManagerBeforeUpload" event:

if(condition) {
    $source->addError('path', 'Some error text');
}

We see our custom error text, but file will uploaded:

screenshot-packages gulomov com-2018 11 24-23-04-35

If we try to use exit, the file won't upload, but we don't see our error text:

if(condition) {
    $source->addError('path', 'Some error text');
    exit;
}

screenshot-packages gulomov com-2018 11 24-23-06-38

Notes

It would be nice if it would be possible to interrupt the file upload.

Environment

MODX Revolution 2.6.5-pl

GulomovCreative commented 5 years ago

Need to set error to true, thanks to @pavel-one

$modx->event->params['file']['error'] = 1;