Commit | Line | Data |
---|---|---|
4bcd4c62 TO |
1 | <?php |
2 | /** | |
3 | * @file | |
4 | * | |
5 | * Activate Civi components on the newly populated database. | |
6 | */ | |
7 | ||
8 | if (!defined('CIVI_SETUP')) { | |
9 | exit("Installation plugins must only be loaded by the installer.\n"); | |
10 | } | |
11 | ||
eb7547e0 TO |
12 | Civi\Setup::dispatcher() |
13 | ->addListener('civi.setup.checkRequirements', function (\Civi\Setup\Event\CheckRequirementsEvent $e) { | |
14 | \Civi\Setup::log()->info(sprintf('[%s] Handle %s', basename(__FILE__), 'checkRequirements')); | |
15 | $model = $e->getModel(); | |
16 | ||
17 | if (empty($model->components)) { | |
18 | $e->addError('system', 'components', "System must have at least one active component."); | |
19 | return; | |
20 | } | |
21 | }); | |
22 | ||
4bcd4c62 TO |
23 | \Civi\Setup::dispatcher() |
24 | ->addListener('civi.setup.installDatabase', function (\Civi\Setup\Event\InstallDatabaseEvent $e) { | |
25 | \Civi\Setup::log()->info('[InstallComponents.civi-setup.php] Activate components: ' . implode(" ", $e->getModel()->components)); | |
26 | ||
27 | if (empty($e->getModel()->components)) { | |
28 | throw new \Exception("System must have at least one active component."); | |
29 | } | |
30 | ||
31 | \Civi::settings()->set('enable_components', $e->getModel()->components); | |
32 | }, \Civi\Setup::PRIORITY_LATE + 300); |