public function __construct($arrAttributes = null)
{
// check against arrAttributes, as 'onsubmit_callback' => 'multifileupload_moveFiles' does not provide valid attributes
if ($arrAttributes !== null && !$arrAttributes['uploadFolder']) {
throw new \Exception(sprintf($GLOBALS['TL_LANG']['ERR']['noUploadFolderDeclared'], $this->name));
}
$arrAttributes['uploadAction'] = static::$uploadAction;
if (TL_MODE == 'FE') {
$arrAttributes['uploadActionParams'] = http_build_query(AjaxAction::getParams(MultiFileUpload::NAME, static::$uploadAction));
}
$arrAttributes['addRemoveLinks'] = isset($arrAttributes['addRemoveLinks']) ? $arrAttributes['addRemoveLinks'] : true;
if (!is_array($arrAttributes['value']) && !Validator::isBinaryUuid($arrAttributes['value'])) {
$arrAttributes['value'] = json_decode($arrAttributes['value']);
}
// bin to string -> never pass binary to the widget!!
if ($arrAttributes['value']) {
if (is_array($arrAttributes['value'])) {
$arrAttributes['value'] = array_map(function ($val) {
return \Validator::isBinaryUuid($val) ? \StringUtil::binToUuid($val) : $val;
}, $arrAttributes['value']);
} else {
$arrAttributes['value'] = array(\Validator::isBinaryUuid($arrAttributes['value']) ? \StringUtil::binToUuid($arrAttributes['value']) : $arrAttributes['value']);
}
}
parent::__construct($arrAttributes);
$this->objUploader = new MultiFileUpload($arrAttributes);
// add onsubmit_callback: move files after form submission
$GLOBALS['TL_DCA'][$this->strTable]['config']['onsubmit_callback']['multifileupload_moveFiles'] = array('HeimrichHannot\\MultiFileUpload\\FormMultiFileUpload', 'moveFiles');
Ajax::runActiveAction(MultiFileUpload::NAME, MultiFileUpload::ACTION_UPLOAD, $this);
}