Josegonzalez\Upload\Model\Behavior\UploadBehavior::beforeMarshal PHP Method

beforeMarshal() public method

Modifies the data being marshalled to ensure invalid upload data is not inserted
public beforeMarshal ( Cake\Event\Event $event, ArrayObject $data, ArrayObject $options ) : void
$event Cake\Event\Event an event instance
$data ArrayObject data being marshalled
$options ArrayObject options for the current event
return void
    public function beforeMarshal(Event $event, ArrayObject $data, ArrayObject $options)
    {
        $validator = $this->_table->validator();
        $dataArray = $data->getArrayCopy();
        foreach (array_keys($this->config()) as $field) {
            if (!$validator->isEmptyAllowed($field, false)) {
                continue;
            }
            if (Hash::get($dataArray, $field . '.error') !== UPLOAD_ERR_NO_FILE) {
                continue;
            }
            unset($data[$field]);
        }
    }