domain.install 756 B

123456789101112131415161718192021222324252627282930313233343536
  1. <?php
  2. /**
  3. * @file
  4. * Install, update and uninstall functions for the Domain Access module.
  5. */
  6. /**
  7. * Implements hook_install().
  8. *
  9. * Installs the domain admin field on users.
  10. */
  11. function domain_install() {
  12. _domain_configure_field();
  13. }
  14. /**
  15. * Implements hook_update_N().
  16. *
  17. * Installs the domain admin field on users.
  18. */
  19. function domain_update_8001() {
  20. _domain_configure_field();
  21. }
  22. /**
  23. * Configures user form display to checkboxes widget for domain admin field.
  24. */
  25. function _domain_configure_field() {
  26. if ($display = \Drupal::entityTypeManager()->getStorage('entity_form_display')->load('user.user.default')) {
  27. $display->setComponent(DOMAIN_ADMIN_FIELD, [
  28. 'type' => 'options_buttons',
  29. 'weight' => 50,
  30. ])->save();
  31. }
  32. }