domain_source.install 819 B

123456789101112131415161718192021222324252627282930
  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 source 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_source_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 source to bundles.
  19. $list = array();
  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_source_confirm_fields($entity_type, $bundle);
  27. }
  28. }