Merge pull request #1197 from SergeyMosin/nexctloud-custom-config

nextcloud: add ability to include custom php file in InstallStep migration
This commit is contained in:
the-djmaze 2023-07-03 15:10:55 +02:00 committed by GitHub
commit 2f746cb262
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -2,6 +2,8 @@
// https://docs.nextcloud.com/server/19/developer_manual/app/repair.html
namespace OCA\SnappyMail\Migration;
use OCA\SnappyMail\AppInfo\Application;
use OCP\IConfig;
use OCP\Migration\IOutput;
use OCP\Migration\IRepairStep;
use OCP\ILogger;
@ -88,5 +90,22 @@ class InstallStep implements IRepairStep
}
$bSave && $oConfig->Save();
// check if admins provided additional/custom initial config file
// https://docs.nextcloud.com/server/latest/admin_manual/configuration_server/occ_command.html#setting-a-single-configuration-value
// ex: php occ config:app:set snappymail custom_config_file --value="/path/to/config.php"
try {
/** @var IConfig $ncConfig */
$ncConfig = \OC::$server->get(IConfig::class);
$customConfigFile = $ncConfig->getAppValue(Application::APP_ID, 'custom_config_file');
if ($customConfigFile && strpos($customConfigFile, ':') === false) {
include $customConfigFile;
}
} catch (\Throwable $e) {
$output->warning("custom config error: " . $e->getMessage());
/** @var \Psr\Log\LoggerInterface $logger */
$logger = \OC::$server->get(\Psr\Log\LoggerInterface::class);
$logger->error("custom config error: " . $e->getMessage());
}
}
}