Initial Drupal 11 with DDEV setup
This commit is contained in:
30
web/core/modules/contact/contact.module
Normal file
30
web/core/modules/contact/contact.module
Normal file
@ -0,0 +1,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();
|
||||
}
|
||||
Reference in New Issue
Block a user