From 965fb8738ba7e1b2ac3d1334226a8bdbecec80c0 Mon Sep 17 00:00:00 2001 From: Mathieu Lutfy Date: Fri, 24 Jun 2022 19:22:23 -0400 Subject: [PATCH] Standalone: add setup plugin so that we can install --- setup/plugins/init/Standalone.civi-setup.php | 52 ++++++++++++++++++++ setup/res/finished.Standalone.php | 16 ++++++ 2 files changed, 68 insertions(+) create mode 100644 setup/plugins/init/Standalone.civi-setup.php create mode 100644 setup/res/finished.Standalone.php diff --git a/setup/plugins/init/Standalone.civi-setup.php b/setup/plugins/init/Standalone.civi-setup.php new file mode 100644 index 0000000000..8b47333fa8 --- /dev/null +++ b/setup/plugins/init/Standalone.civi-setup.php @@ -0,0 +1,52 @@ +addListener('civi.setup.checkAuthorized', function (\Civi\Setup\Event\CheckAuthorizedEvent $e) { + $model = $e->getModel(); + if ($model->cms !== 'Standalone') { + return; + } + + \Civi\Setup::log()->info(sprintf('[%s] Handle %s', basename(__FILE__), 'checkAuthorized')); + $e->setAuthorized(TRUE); + }); + + +\Civi\Setup::dispatcher() + ->addListener('civi.setup.init', function (\Civi\Setup\Event\InitEvent $e) { + $model = $e->getModel(); + if ($model->cms !== 'Standalone') { + return; + } + \Civi\Setup::log()->info(sprintf('[%s] Handle %s', basename(__FILE__), 'init')); + + // Compute settingsPath. + // We use this structure: /var/www/standalone/data/{civicrm.settings.php,templates_c} + // to reduce the number of directories that admins have to chmod + $model->settingsPath = implode(DIRECTORY_SEPARATOR, [$model->webroot, 'data', 'civicrm.settings.php']); + $model->templateCompilePath = implode(DIRECTORY_SEPARATOR, [$model->webroot, 'data', 'templates_c']); + + // Compute DSN. + $model->db = $model->cmsDb = [ + 'server' => 'localhost', + 'username' => '', + 'password' => '', + 'database' => '', + ]; + + // Compute URLs (@todo?) + $model->cmsBaseUrl = $_SERVER['HTTP_ORIGIN'] ?: $_SERVER['HTTP_REFERER']; + $model->mandatorySettings['userFrameworkResourceURL'] = $model->cmsBaseUrl . '/assets/civicrm/core'; + + // Compute default locale. + $model->lang = $_REQUEST['lang'] ?? 'en_US'; + }); diff --git a/setup/res/finished.Standalone.php b/setup/res/finished.Standalone.php new file mode 100644 index 0000000000..65002c8c15 --- /dev/null +++ b/setup/res/finished.Standalone.php @@ -0,0 +1,16 @@ + +

+
+

+ +

+ + +

+
-- 2.25.1