public function disableSubmit(array &$form, FormStateInterface $form_state)
    {
        $types = array();
        foreach ($form_state->getValue('types') as $type => $selected) {
            if ($type === $selected) {
                $types[] = $type;
            }
        }

        if (empty($types)) {
            drupal_set_message($this->t("Nothing to do"));
            return;
        }

        $disabled = variable_get(APB_VAR_ENABLED_TYPES, []);
        $disabled += $types;

        if (empty($disabled)) {
            variable_set(APB_VAR_ENABLED_TYPES, null);
        } else {
            variable_set(APB_VAR_ENABLED_TYPES, array_unique($disabled));
        }

        drupal_set_message($this->t("Disabled selected types"));
    }
public function disableSubmit(array &$form, FormStateInterface $form_state)
    {
        $types = array();
        foreach ($form_state->getValue('types') as $type => $selected) {
            if ($type === $selected) {
                $types[] = $type;
            }
        }

        if (empty($types)) {
            drupal_set_message($this->t("Nothing to do"));
            return;
        }

        $disabled = variable_get(APB_VAR_ENABLED_TYPES, []);
        $disabled += $types;

        if (empty($disabled)) {
            variable_set(APB_VAR_ENABLED_TYPES, null);
        } else {
            variable_set(APB_VAR_ENABLED_TYPES, array_unique($disabled));
        }

        drupal_set_message($this->t("Disabled selected types"));
    }
public function disableSubmit ( array & $ form , FormStateInterface $ form_state ) { $ types = array ( ) ; foreach ( $ form_state -> getValue ( 'types' ) as $ type => $ selected ) { if ( $ type === $ selected ) { $ types [ ] = $ type ; } } if ( empty ( $ types ) ) { drupal_set_message ( $ this -> t ( "Nothing to do" ) ) ; return ; } $ disabled = variable_get ( APB_VAR_ENABLED_TYPES , [ ] ) ; $ disabled += $ types ; if ( empty ( $ disabled ) ) { variable_set ( APB_VAR_ENABLED_TYPES , null ) ; } else { variable_set ( APB_VAR_ENABLED_TYPES , array_unique ( $ disabled ) ) ; } drupal_set_message ( $ this -> t ( "Disabled selected types" ) ) ; }
Notification types admin form disable selected submit handler
Notification types admin form disable selected submit handler