You are here

function flag_lists_save_submit in Flag Lists 8

Same name and namespace in other branches
  1. 4.0.x flag_lists.module \flag_lists_save_submit()

Form submission handler for the 'save' action.

Parameters

array $form: An associative array containing the structure of the form.

\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.

1 string reference to 'flag_lists_save_submit'
flag_lists_form_alter in ./flag_lists.module
Implements hook_form_alter().

File

./flag_lists.module, line 225
Contains flag_lists.module.

Code

function flag_lists_save_submit(array &$form, FormStateInterface $form_state) {
  if ($form_state
    ->getValue('flag_lists_flag')) {
    $flagListsService = \Drupal::service('flaglists');
    if (empty($form['#flag']
      ->id())) {

      // This is a new Flag and Flag List Template.
      FlagTracker::save($form, $form_state);
    }
    elseif (!empty($flagTemplate = $flagListsService
      ->getFlagForListById($form['#flag']
      ->id()))) {

      // The Flag has already a Flag For List.
      FlagTracker::update($form, $form_state, $flagTemplate);
    }
    else {

      // Existing Flag without a Flag For List.
      FlagTracker::save($form, $form_state);
    }
  }
}