Merge pull request #19594 from eileenmcnaughton/535m
[civicrm-core.git] / setup / plugins / installDatabase / InstallComponents.civi-setup.php
index e5a6b0b5d64341e4487ce3cc5b44ad800104d2bd..88170571b5dc05283476e6b6ea6522c5c936fc93 100644 (file)
@@ -9,6 +9,17 @@ if (!defined('CIVI_SETUP')) {
   exit("Installation plugins must only be loaded by the installer.\n");
 }
 
+Civi\Setup::dispatcher()
+  ->addListener('civi.setup.checkRequirements', function (\Civi\Setup\Event\CheckRequirementsEvent $e) {
+    \Civi\Setup::log()->info(sprintf('[%s] Handle %s', basename(__FILE__), 'checkRequirements'));
+    $model = $e->getModel();
+
+    if (empty($model->components)) {
+      $e->addError('system', 'components', "System must have at least one active component.");
+      return;
+    }
+  });
+
 \Civi\Setup::dispatcher()
   ->addListener('civi.setup.installDatabase', function (\Civi\Setup\Event\InstallDatabaseEvent $e) {
     \Civi\Setup::log()->info('[InstallComponents.civi-setup.php] Activate components: ' . implode(" ", $e->getModel()->components));