You are here

function mass_contact_install in Mass Contact 8

Same name and namespace in other branches
  1. 5.2 mass_contact.install \mass_contact_install()
  2. 5 mass_contact.install \mass_contact_install()
  3. 6 mass_contact.install \mass_contact_install()
  4. 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();
  }
}