1 | <?php |
||
2 | |||
3 | namespace SilverCommerce\Settings\Extensions; |
||
4 | |||
5 | use NumberFormatter; |
||
6 | use SilverStripe\Core\Environment; |
||
7 | use SilverStripe\i18n\i18n; |
||
8 | use SilverStripe\Core\Extension; |
||
9 | use SilverStripe\Dev\DevelopmentAdmin; |
||
10 | use SilverStripe\SiteConfig\SiteConfig; |
||
0 ignored issues
–
show
|
|||
11 | use SilverStripe\Dev\DevBuildController; |
||
12 | use SilverStripe\ORM\FieldType\DBCurrency; |
||
13 | use SilverStripe\ORM\DatabaseAdmin; |
||
14 | |||
15 | class ControllerExtension extends Extension |
||
16 | { |
||
17 | /** |
||
18 | * Customise the default silverstripe locale config |
||
19 | */ |
||
20 | public function onBeforeInit() |
||
21 | { |
||
22 | $tests = Environment::getEnv('UNIT_TESTS_RUNNING'); |
||
23 | $disallowed_controllers = [ |
||
24 | DevelopmentAdmin::class, |
||
25 | DevBuildController::class, |
||
26 | DatabaseAdmin::class |
||
27 | ]; |
||
28 | |||
29 | // Don't run this during dev/build or dev/tasks or when unit tests are running |
||
30 | if (!$tests && !in_array(get_class($this->owner), $disallowed_controllers)) { |
||
31 | // Set global local based on Site Config |
||
32 | $config = SiteConfig::current_site_config(); |
||
33 | i18n::set_locale($config->SiteLocale); |
||
34 | |||
35 | // Now find and set the desired currency symbol |
||
36 | $number_format = new NumberFormatter($config->SiteLocale, NumberFormatter::CURRENCY); |
||
37 | $symbol = $number_format->getSymbol(NumberFormatter::CURRENCY_SYMBOL); |
||
38 | DBCurrency::config()->currency_symbol = $symbol; |
||
39 | } |
||
40 | } |
||
41 | } |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths