Skip to content

Commit

Permalink
Extend Config
Browse files Browse the repository at this point in the history
  • Loading branch information
dragomano committed Apr 27, 2024
1 parent 552f3f9 commit c3073d5
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ Or you can leave it as it is. In this case, your modification will support both
| `getCalendarList` | `Calendar::getCalendarList` |
| `getCalendarGrid` | `Calendar::getCalendarGrid` |
| `updateSettings` | `Config::updateModSettings` |
| `updateSettingsFile` | `Config::updateSettingsFile` |
| `db_extend` | `Db::extend` |
| `create_control_richedit` | `new Editor` |
| `fatal_error` | `ErrorHandler::fatal` |
Expand Down
1 change: 1 addition & 0 deletions README.ru.md
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ class Example
| `getCalendarList` | `Calendar::getCalendarList` |
| `getCalendarGrid` | `Calendar::getCalendarGrid` |
| `updateSettings` | `Config::updateModSettings` |
| `updateSettingsFile` | `Config::updateSettingsFile` |
| `db_extend` | `Db::extend` |
| `create_control_richedit` | `new Editor` |
| `fatal_error` | `ErrorHandler::fatal` |
Expand Down
8 changes: 8 additions & 0 deletions src/Compat/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
namespace Bugo\Compat;

use function updateSettings;
use function updateSettingsFile;

class Config
{
Expand Down Expand Up @@ -84,4 +85,11 @@ public static function updateModSettings(array $settings): void
{
updateSettings($settings);
}

public static function updateSettingsFile(array $config_vars, ?bool $keep_quotes = null, bool $rebuild = false): bool
{
require_once self::$sourcedir . DIRECTORY_SEPARATOR . 'Subs-Admin.php';

return updateSettingsFile($config_vars, $keep_quotes, $rebuild);
}
}
6 changes: 6 additions & 0 deletions tests/Unit/ConfigTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,9 @@

expect(Config::$modSettings['foo'])->toBe('bar');
});

test('updateSettingsFile method', function () {
$this->config::$sourcedir = dirname(__DIR__) . '/files';

expect($this->config::updateSettingsFile(['foo' => 'bar']))->toBeBool();
});
7 changes: 7 additions & 0 deletions tests/files/Subs-Admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,10 @@ function sm_temp_dir(): string
return '';
}
}

if (! function_exists('updateSettingsFile')) {
function updateSettingsFile(...$args): bool
{
return true;
}
}

0 comments on commit c3073d5

Please sign in to comment.