コード例 #1
0
ファイル: FormController.php プロジェクト: isramv/camp-gdl
 /**
  * Form submit handler to flush Mollom session and form information from cache.
  *
  * This is necessary as the entity forms will no longer automatically save
  * the data with the entity.
  *
  * @todo: Possible problems:
  *   - This submit handler is invoked too late; the primary submit handler might
  *     send out e-mails directly after saving the entity (e.g.,
  *     user_register_form_submit()), so mollom_mail_alter() is invoked before
  *     Mollom session data has been saved.
  */
 public static function submitForm($form, FormState $form_state)
 {
     // Some modules are implementing multi-step forms without separate form
     // submit handlers. In case we reach here and the form will be rebuilt, we
     // need to defer our submit handling until final submission.
     $is_rebuilding = $form_state->isRebuilding();
     if ($is_rebuilding) {
         return;
     }
     $mollom = $form_state->getValue('mollom');
     $form_object = $form_state->getFormObject();
     // If an 'entity' and a 'post_id' mapping was provided via
     // hook_mollom_form_info(), try to automatically store Mollom session data.
     if (empty($mollom) || empty($mollom['entity']) || !$form_state->getFormObject() instanceof EntityFormInterface) {
         return;
     }
     /* @var $form_object \Drupal\Core\Entity\EntityFormInterface */
     $entity_id = $form_object->getEntity()->id();
     $data = (object) $mollom;
     $data->id = $entity_id;
     $data->moderate = $mollom['require_moderation'] ? 1 : 0;
     $stored_data = ResponseDataStorage::save($data);
     $form_state->setValue(['mollom', 'data'], $stored_data);
 }