function mass_contact_install in Mass Contact 8
Same name and namespace in other branches
- 5.2 mass_contact.install \mass_contact_install()
- 5 mass_contact.install \mass_contact_install()
- 6 mass_contact.install \mass_contact_install()
- 7 mass_contact.install \mass_contact_install()
Implements hook_install().
File
- ./
mass_contact.install, line 13 - Install hooks for the mass contact module.
Code
function mass_contact_install() {
// Add the `mass_contact_opt_out` field to the user form.
$display = \Drupal::service('entity_display.repository')
->getFormDisplay('user', 'user', 'default');
if (!$display
->getComponent(MassContactInterface::OPT_OUT_FIELD_ID)) {
$settings = [
'type' => 'options_buttons',
'settings' => [],
];
$display
->setComponent(MassContactInterface::OPT_OUT_FIELD_ID, $settings);
$display
->save();
}
}