mass_contact.install in Mass Contact 8
Same filename and directory in other branches
Install hooks for the mass contact module.
File
mass_contact.installView source
<?php
/**
* @file
* Install hooks for the mass contact module.
*/
use Drupal\mass_contact\MassContactInterface;
/**
* Implements hook_install().
*/
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();
}
}
/**
* Implements hook_unistall().
*/
function mass_contact_uninstall() {
//Removing mass_contact_opt_out field.
Drupal::configFactory()
->getEditable('field.field.user.user.mass_contact_opt_out')
->delete();
Drupal::configFactory()
->getEditable('field.storage.user.mass_contact_opt_out')
->delete();
}
Functions
Name | Description |
---|---|
mass_contact_install | Implements hook_install(). |
mass_contact_uninstall | Implements hook_unistall(). |