Commit | Line | Data |
---|---|---|
4bcd4c62 TO |
1 | <?php |
2 | /** | |
3 | * @file | |
4 | * | |
5 | * Verify that the CMS base URL is well-formed. | |
6 | * | |
7 | * Ex: When installing via CLI, the URL cannot be determined automatically. | |
8 | */ | |
9 | ||
10 | if (!defined('CIVI_SETUP')) { | |
11 | exit("Installation plugins must only be loaded by the installer.\n"); | |
12 | } | |
13 | ||
14 | \Civi\Setup::dispatcher() | |
15 | ->addListener('civi.setup.checkRequirements', function (\Civi\Setup\Event\CheckRequirementsEvent $e) { | |
16 | \Civi\Setup::log()->info(sprintf('[%s] Handle %s', basename(__FILE__), 'checkRequirements')); | |
17 | $model = $e->getModel(); | |
18 | ||
19 | if (!$model->cmsBaseUrl) { | |
20 | return; | |
21 | } | |
22 | ||
23 | if (\Civi\Setup\DrupalUtil::isDrush() && preg_match(';^https?://default/?;', $model->cmsBaseUrl)) { | |
24 | // If you run "drush8 en civicrm", it may fabricate the URL as "http://default/". Not good enough b/c this will be stored for future use.. | |
25 | $e->addError('system', 'drushUrl', "Please specify a realistic site URL (Ex: drush -l http://example.com:456 ...)."); | |
26 | } | |
27 | }); |