コード例 #1
0
ファイル: Processor.php プロジェクト: pkdevboxy/boltforms
 /**
  * Process the fields to get usable data.
  *
  * @param FormConfig $formConfig
  * @param FormData   $formData
  *
  * @throws FileUploadException
  */
 protected function processFields(FormConfig $formConfig, FormData $formData)
 {
     foreach ($formData->keys() as $fieldName) {
         $field = $formData->get($fieldName);
         // Handle file uploads
         if ($field instanceof UploadedFile) {
             if (!$field->isValid()) {
                 throw new FileUploadException($field->getErrorMessage());
             }
             // Get the upload object
             $formData->set($fieldName, new FileUpload($this->app, $formConfig->getName(), $field));
             if (!$this->config['uploads']['enabled']) {
                 $this->app['logger.system']->debug('[BoltForms] File upload skipped as the administrator has disabled uploads for all forms.', ['event' => 'extensions']);
                 continue;
             }
             // Take configured actions on the file
             $formData->get($fieldName)->move();
         }
         // Handle events for custom data
         $fieldConf = $formConfig->getFields()->{$fieldName}();
         if (isset($fieldConf['event']['name'])) {
             $formData->set($fieldName, $this->dispatchCustomDataEvent($fieldConf['event']));
         }
     }
 }