blob: 182e2f2c0767beda5940d57944bd14a43c3866e2 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
<?php
/**
* @file
*/
use Drupal\Core\Form\FormStateInterface;
/**
* Form submission handler for \Drupal\user\ProfileForm.
*
* Saves the contact page setting.
*/
function contact_user_profile_form_submit($form, FormStateInterface $form_state): void {
$account = $form_state->getFormObject()->getEntity();
if ($account->id() && $form_state->hasValue('contact')) {
\Drupal::service('user.data')->set('contact', $account->id(), 'enabled', (int) $form_state->getValue('contact'));
}
}
/**
* Form submission handler for \Drupal\user\AccountSettingsForm.
*
* @see contact_form_user_admin_settings_alter()
*/
function contact_form_user_admin_settings_submit($form, FormStateInterface $form_state): void {
\Drupal::configFactory()->getEditable('contact.settings')
->set('user_default_enabled', $form_state->getValue('contact_default_status'))
->save();
}
|