domain_access.install 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  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 default domain field on nodes. We don't do this via schema.yml
  10. * files because we have an unknown number of node types.
  11. */
  12. function domain_access_install() {
  13. if (\Drupal::isConfigSyncing()) {
  14. // Configuration is assumed to already be checked by the config importer
  15. // validation events.
  16. return;
  17. }
  18. // Assign domain access to bundles.
  19. $list['user'] = 'user';
  20. $node_types = \Drupal::entityTypeManager()->getStorage('node_type')->loadMultiple();
  21. foreach ($node_types as $type => $info) {
  22. $list[$type] = 'node';
  23. }
  24. // Install our fields.
  25. foreach ($list as $bundle => $entity_type) {
  26. domain_access_confirm_fields($entity_type, $bundle);
  27. }
  28. // Install our actions.
  29. $domains = \Drupal::entityTypeManager()->getStorage('domain')->loadMultiple();
  30. foreach ($domains as $domain) {
  31. domain_access_domain_insert($domain);
  32. }
  33. }
  34. /**
  35. * Add the setting to open the domain access fieldset.
  36. */
  37. function domain_access_update_8001() {
  38. $config_factory = \Drupal::configFactory();
  39. $config = $config_factory->getEditable('domain_access.settings');
  40. $config->set('node_advanced_tab_open', 0);
  41. $config->save(TRUE);
  42. }