original_string: public function beforeMarshal(Event $event, ArrayObject $data, ArrayObject $options) {
          // configuration set?
          $this->check();
  
          // load validator and add our custom upload validator
          $validator = $this->_table->getValidator();
          $validator->setProvider('upload', UploadValidation::class);
  
          // go through each field
          foreach($this->_config['fields'] as $field => $path) {
              // add validators
              $validator->add($field, [
                  'isUnderPhpSizeLimit' => ['rule' => 'isUnderPhpSizeLimit', 'provider' => 'upload', 'message' => __d('Unimatrix/cake', 'This file is too large')],
                  'isUnderFormSizeLimit' => ['rule' => 'isUnderFormSizeLimit', 'provider' => 'upload', 'message' => __d('Unimatrix/cake', 'This file is too large')],
                  'isCompletedUpload' => ['rule' => 'isCompletedUpload', 'provider' => 'upload', 'message' => __d('Unimatrix/cake', 'This file was only partially uploaded')],
                  'isTemporaryDirectory' => ['rule' => 'isTemporaryDirectory', 'provider' => 'upload', 'message' => __d('Unimatrix/cake', 'Missing a temporary folder')],
                  'isSuccessfulWrite' => ['rule' => 'isSuccessfulWrite', 'provider' => 'upload', 'message' => __d('Unimatrix/cake', 'Failed to write file to disk')],
                  'isNotStoppedByExtension' => ['rule' => 'isNotStoppedByExtension', 'provider' => 'upload', 'message' => __d('Unimatrix/cake', 'Upload was stopped by extension')],
              ]);
  
              // empty allowed? && no file uploaded? unset field
              if($validator->isEmptyAllowed($field, false)
                  && isset($data[$field]['error']) && $data[$field]['error'] === UPLOAD_ERR_NO_FILE)
                      unset($data[$field]);
          }
      }
code: public function beforeMarshal(Event $event, ArrayObject $data, ArrayObject $options) {
          // configuration set?
          $this->check();
  
          // load validator and add our custom upload validator
          $validator = $this->_table->getValidator();
          $validator->setProvider('upload', UploadValidation::class);
  
          // go through each field
          foreach($this->_config['fields'] as $field => $path) {
              // add validators
              $validator->add($field, [
                  'isUnderPhpSizeLimit' => ['rule' => 'isUnderPhpSizeLimit', 'provider' => 'upload', 'message' => __d('Unimatrix/cake', 'This file is too large')],
                  'isUnderFormSizeLimit' => ['rule' => 'isUnderFormSizeLimit', 'provider' => 'upload', 'message' => __d('Unimatrix/cake', 'This file is too large')],
                  'isCompletedUpload' => ['rule' => 'isCompletedUpload', 'provider' => 'upload', 'message' => __d('Unimatrix/cake', 'This file was only partially uploaded')],
                  'isTemporaryDirectory' => ['rule' => 'isTemporaryDirectory', 'provider' => 'upload', 'message' => __d('Unimatrix/cake', 'Missing a temporary folder')],
                  'isSuccessfulWrite' => ['rule' => 'isSuccessfulWrite', 'provider' => 'upload', 'message' => __d('Unimatrix/cake', 'Failed to write file to disk')],
                  'isNotStoppedByExtension' => ['rule' => 'isNotStoppedByExtension', 'provider' => 'upload', 'message' => __d('Unimatrix/cake', 'Upload was stopped by extension')],
              ]);
  
              // empty allowed? && no file uploaded? unset field
              if($validator->isEmptyAllowed($field, false)
                  && isset($data[$field]['error']) && $data[$field]['error'] === UPLOAD_ERR_NO_FILE)
                      unset($data[$field]);
          }
      }
code_tokens: public function beforeMarshal ( Event $ event , ArrayObject $ data , ArrayObject $ options ) { // configuration set? $ this -> check ( ) ; // load validator and add our custom upload validator $ validator = $ this -> _table -> getValidator ( ) ; $ validator -> setProvider ( 'upload' , UploadValidation :: class ) ; // go through each field foreach ( $ this -> _config [ 'fields' ] as $ field => $ path ) { // add validators $ validator -> add ( $ field , [ 'isUnderPhpSizeLimit' => [ 'rule' => 'isUnderPhpSizeLimit' , 'provider' => 'upload' , 'message' => __d ( 'Unimatrix/cake' , 'This file is too large' ) ] , 'isUnderFormSizeLimit' => [ 'rule' => 'isUnderFormSizeLimit' , 'provider' => 'upload' , 'message' => __d ( 'Unimatrix/cake' , 'This file is too large' ) ] , 'isCompletedUpload' => [ 'rule' => 'isCompletedUpload' , 'provider' => 'upload' , 'message' => __d ( 'Unimatrix/cake' , 'This file was only partially uploaded' ) ] , 'isTemporaryDirectory' => [ 'rule' => 'isTemporaryDirectory' , 'provider' => 'upload' , 'message' => __d ( 'Unimatrix/cake' , 'Missing a temporary folder' ) ] , 'isSuccessfulWrite' => [ 'rule' => 'isSuccessfulWrite' , 'provider' => 'upload' , 'message' => __d ( 'Unimatrix/cake' , 'Failed to write file to disk' ) ] , 'isNotStoppedByExtension' => [ 'rule' => 'isNotStoppedByExtension' , 'provider' => 'upload' , 'message' => __d ( 'Unimatrix/cake' , 'Upload was stopped by extension' ) ] , ] ) ; // empty allowed? && no file uploaded? unset field if ( $ validator -> isEmptyAllowed ( $ field , false ) && isset ( $ data [ $ field ] [ 'error' ] ) && $ data [ $ field ] [ 'error' ] === UPLOAD_ERR_NO_FILE ) unset ( $ data [ $ field ] ) ; } }
docstring: If a field is allowed to be empty as defined in the validation it should be unset to prevent processing
  @param \Cake\Event\Event $event Event instance
  @param ArrayObject $data Data to process
  @return void
docstring_tokens: If a field is allowed to be empty as defined in the validation it should be unset to prevent processing