You are here

public function AvatarKitServicesForm::submitForm in Avatar Kit 8.2

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 ConfigFormBase::submitForm

File

src/Form/AvatarKitServicesForm.php, line 125

Class

AvatarKitServicesForm
Configure Avatar Kit services.

Namespace

Drupal\avatars\Form

Code

public function submitForm(array &$form, FormStateInterface $form_state) : void {
  parent::submitForm($form, $form_state);

  // Invalidate cached preferences for entities.
  $this->preferenceCacheBackend
    ->invalidateAll();

  // Generators are already sorted correctly.
  foreach ($form_state
    ->getValue('services') as $id => $row) {

    /** @var \Drupal\avatars\Entity\AvatarKitService $instance */
    $instance = AvatarKitService::load($id);
    $instance
      ->setWeight($row['weight'])
      ->save();
  }
}