Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nextcloud: add ability to include custom php file in InstallStep migration #1197

Merged
merged 1 commit into from
Jul 3, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions integrations/nextcloud/snappymail/lib/Migration/InstallStep.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -88,5 +90,22 @@ public function run(IOutput $output) {
}

$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());
}
}
}