You are here

public function FlexiformBuilderFlexiform::save in Flexiform 7

Save everything.

Parameters

\FlexiformFormEntityManagerInterface $entity_manager:

array $form_state:

1 call to FlexiformBuilderFlexiform::save()
FlexiformBuilderFlexiform::formSubmit in includes/builder/flexiform.builder.inc
Submit the form.

File

includes/builder/flexiform.builder.inc, line 205
Contains the FlexiformBuilderFlexiform Class

Class

FlexiformBuilderFlexiform
Flexiform Builder Class for the complex flexiforms.

Code

public function save(FlexiformFormEntityManagerInterface $entity_manager, $form_state = array()) {
  $entity_manager
    ->saveEntities();
  if (module_exists('rules')) {
    $base_entity_wrapper = entity_metadata_wrapper($this->flexiform->base_entity, $entity_manager
      ->getEntity('base_entity'));
    $args = array(
      'base_entity' => $base_entity_wrapper,
    );

    // All Arguments: Rules needs nulls as null rather than false.
    $all_args = $entity_manager
      ->getEntities();
    foreach ($all_args as &$ent) {
      if (empty($ent)) {
        $ent = NULL;
      }
    }

    // Fire the most specific rules first and track back to the less specific.
    $rule_name = 'flexiform_submit_' . $this->flexiform->form;
    drupal_alter('flexiform_rules_arguments', $all_args, $form_state, $rule_name);
    rules_invoke_event_by_args('flexiform_submit_' . $this->flexiform->form, $all_args);
    $rule_name = 'flexiform_group_submit_' . $this->flexiform->form_group;
    drupal_alter('flexiform_rules_arguments', $args, $form_state, $rule_name);
    rules_invoke_event_by_args('flexiform_group_submit_' . $this->flexiform->form_group, $args);
    $rule_name = 'flexiform_any_submit';
    drupal_alter('flexiform_rules_arguments', $args, $form_state, $rule_name);
    rules_invoke_event_by_args('flexiform_any_submit', $args);
  }
}