You are here

public function AddCustomPlaceForm::submitForm in Weather 2.0.x

Same name and namespace in other branches
  1. 8 src/Form/AddCustomPlaceForm.php \Drupal\weather\Form\AddCustomPlaceForm::submitForm()

Form submission handler.

Parameters

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

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

Overrides FormInterface::submitForm

File

src/Form/AddCustomPlaceForm.php, line 201

Class

AddCustomPlaceForm
Configure Weather settings for this site.

Namespace

Drupal\weather\Form

Code

public function submitForm(array &$form, FormStateInterface $form_state) {
  $url = $form_state
    ->getValue('weather_yrno_url');
  $url = trim($url) . 'forecast.xml';
  if ($this->weatherParser
    ->downloadForecast('', $url)) {
    $this->messenger
      ->addStatus($this
      ->t('The new place has been saved.'));
  }
  else {
    $this->messenger
      ->addError($this
      ->t('The download from the given URL did not succeed.'));
  }
}