Issue #3588707: Upgrading from 2.x to 3.x crashes when domain_config is not enabled

Issue: https://www.drupal.org/project/domain_theme_switch/issues/3588707

Summary

Adds hook_requirements('update') so that 2.x → 3.x upgraders get a clear, actionable message when the new domain_config dependency has not yet been enabled, instead of a ServiceNotFoundException from update_10001().

Mechanism

drush updb / update.php invoke hook_requirements('update') before running any hook_update_N. The new gate detects the missing domain_config module and aborts the update run with REQUIREMENT_ERROR. Recovery for upgraders becomes:

composer update drupal/domain drupal/domain_theme_switch
drush updb           # blocked with a clear message
drush en domain_config
drush updb           # passes; update_10001 migrates the config

Implementation

Implemented as an OOP service DomainThemeSwitchRequirements (with ModuleHandlerInterface injected and StringTranslationTrait), wired in domain_theme_switch.services.yml. The procedural domain_theme_switch_requirements() in domain_theme_switch.install delegates to the service and is annotated with #[LegacyRequirementsHook] to stay compatible with Drupal 10.

hook_requirements() is in the OOP hook deny-list, so a procedural function is still required; the OOP service keeps the actual logic testable and consistent with the existing Drupal\domain_theme_switch\Hook\DomainThemeSwitchHooks pattern.

Files changed

  • src/Hook/DomainThemeSwitchRequirements.php (new) — OOP requirements service
  • domain_theme_switch.install — procedural delegate with #[LegacyRequirementsHook]
  • domain_theme_switch.services.yml — service registration
  • README.md — Dependencies updated to list domain_config; new “Upgrading from 2.x to 3.x” section

Merge request reports

Loading