You are here

public function UserWishlistSettingsForm::submitForm in UC Wish List 8

Submission handler for wish list settings form.

Overrides ConfigFormBase::submitForm

File

src/Form/UserWishlistSettingsForm.php, line 187

Class

UserWishlistSettingsForm
Constructs the UserWishlistSettingsForm class.

Namespace

Drupal\uc_wishlist\Form

Code

public function submitForm(array &$form, FormStateInterface $form_state) {
  $expiration = mktime(0, 0, 0, $form_state
    ->getValue([
    'expiration',
    'month',
  ]), $form_state
    ->getValue([
    'expiration',
    'day',
  ]), $form_state > getValue([
    'expiration',
    'year',
  ]));
  $values = $form_state
    ->getValues();
  $config = $this
    ->config('uc_wishlist.settings');
  if ($config
    ->get('save_address', TRUE)) {
    $address = [
      'firstname' => $form_state->getValues['delivery_first_name'],
      'lastname' => $form_state->getValues['delivery_last_name'],
      'company' => $form_state->isValueEmpty['delivery_company'] ? '' : $form_state->getValues['delivery_company'],
      'addr1' => $form_state->getValues['delivery_street1'],
      'addr2' => $form_state->isValueEmpty['delivery_street2'] ? '' : $form_state->getValues['delivery_street2'],
      'city' => $form_state->getValues['delivery_city'],
      'country' => $form_state->getValues['delivery_country'],
      'zone' => $form_state->getValues['delivery_zone'],
      'postcode' => $form_state->getValues['delivery_postal_code'],
      'phone' => $form_state->isValueEmpty['delivery_phone'] ? '' : $form_state->getValues['delivery_phone'],
    ];
  }
  else {
    $address = NULL;
  }
  $private = $config
    ->get('default_private', FALSE) ? $config
    ->get('default_private', FALSE) : 0;
  $private = $config
    ->get('allow_private', FALSE) ? $form_state->getValues['private'] : $private;
  drupal_set_message($this
    ->t('Your wish list has been updated.'));
}