You are here

public function AccountSettingsForm::submitForm in Optimizely 8.3

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/AccountSettingsForm.php, line 64

Class

AccountSettingsForm
Implements the form for Account Info.

Namespace

Drupal\optimizely\Form

Code

public function submitForm(array &$form, FormStateInterface $form_state) {

  // Store the optimizely account id number.
  $optimizely_id = $form_state
    ->getValue('optimizely_id');
  AccountId::setId($optimizely_id);

  // Update the default project / experiment entry with the account ID value.
  \Drupal::database()
    ->update('optimizely')
    ->fields([
    'project_code' => $optimizely_id,
  ])
    ->condition('oid', '1')
    ->execute();

  // Inform the administrator that the default project / experiment entry
  // is ready to be enabled.
  drupal_set_message(t('The default project entry is now ready to be enabled.
       This will apply the default Optimizely project tests sitewide.'), 'status');

  // Redirect back to projects listing.
  $form_state
    ->setRedirect('optimizely.listing');
}