Merge pull request #16615 from MegaphoneJon/selfsfc-refactor
[civicrm-core.git] / setup / plugins / blocks / advanced.civi-setup.php
1 <?php
2 if (!defined('CIVI_SETUP')) {
3 exit("Installation plugins must only be loaded by the installer.\n");
4 }
5
6 \Civi\Setup::dispatcher()
7 ->addListener('civi.setupui.run', function (\Civi\Setup\UI\Event\UIBootEvent $e) {
8
9 \Civi\Setup::log()->info(sprintf('[%s] Parse inputs', basename(__FILE__)));
10
11 /**
12 * @var \Civi\Setup\UI\SetupController $ctrl
13 */
14 $ctrl = $e->getCtrl();
15 $values = $e->getField('advanced', array());
16
17 $placeholderDb = 'mysql://USER:PASS@HOST/DB';
18
19 if (empty($values['db']) || $values['db'] === $placeholderDb) {
20 $e->getModel()->extras['advanced']['db'] = $placeholderDb;
21 }
22 else {
23 $e->getModel()->extras['advanced']['db'] = trim($values['db']);
24 $e->getModel()->db = \Civi\Setup\DbUtil::parseDsn(trim($values['db']));
25 }
26
27 }, \Civi\Setup::PRIORITY_LATE);
28
29 \Civi\Setup::dispatcher()
30 ->addListener('civi.setupui.boot', function (\Civi\Setup\UI\Event\UIBootEvent $e) {
31 \Civi\Setup::log()->info(sprintf('[%s] Register blocks', basename(__FILE__)));
32
33 /**
34 * @var \Civi\Setup\UI\SetupController $ctrl
35 */
36 $ctrl = $e->getCtrl();
37
38 $ctrl->blocks['advanced'] = array(
39 'is_active' => TRUE,
40 'file' => __DIR__ . DIRECTORY_SEPARATOR . 'advanced.tpl.php',
41 'class' => '',
42 'weight' => 60,
43 );
44 }, \Civi\Setup::PRIORITY_PREPARE);