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

fix: settings extender working only with first instances #3439

Merged
merged 2 commits into from
May 24, 2022
Merged
Show file tree
Hide file tree
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
2 changes: 2 additions & 0 deletions framework/core/src/Extend/Settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,8 @@ public function extend(Container $container, Extension $extension = null)

$defaults->put($key, $value);
}

return $defaults;
});
}

Expand Down
12 changes: 7 additions & 5 deletions framework/core/tests/integration/extenders/SettingsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -173,14 +173,16 @@ public function custom_setting_default_prioritizes_extender()
(new Extend\Settings())
->serializeToForum('customPrefix.unavailableCustomSetting3', 'custom-prefix.unavailable_custom_setting3')
->default('custom-prefix.unavailable_custom_setting3', 'extenderDefault')
->default('custom-prefix.unavailable_custom_setting100', 'extenderDefault100'),
(new Extend\Settings())
->default('custom-prefix.unavailable_custom_setting200', 'extenderDefault200')
);

$value = $this->app()
->getContainer()
->make('flarum.settings')
->get('custom-prefix.unavailable_custom_setting3', 'defaultParameterValue');
$settings = $this->app()->getContainer()->make('flarum.settings');

$this->assertEquals('extenderDefault', $value);
$this->assertEquals('extenderDefault', $settings->get('custom-prefix.unavailable_custom_setting3'));
$this->assertEquals('extenderDefault100', $settings->get('custom-prefix.unavailable_custom_setting100'));
$this->assertEquals('extenderDefault200', $settings->get('custom-prefix.unavailable_custom_setting200'));
}

/**
Expand Down