Skip to content

Commit 35bf2fa

Browse files
committed
feature #32543 [FrameworkBundle] add config translator cache_dir (Raulnet)
This PR was submitted for the 4.3 branch but it was squashed and merged into the 4.4 branch instead (closes #32543). Discussion ---------- [FrameworkBundle] add config translator cache_dir | Q | A | ------------- | --- | Branch? | 4.4 (be careful when merging) | Bug fix? | no | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #32542 | License | MIT Now the parameter cache_dir of Translator constructor can be change or disable on config ```yaml #framework.yaml framework: ... translator: cache_dir: null #(cache disable) ... ``` Commits ------- 7613c7d [FrameworkBundle] add config translator cache_dir
2 parents 7479543 + 7613c7d commit 35bf2fa

File tree

11 files changed

+43
-2
lines changed

11 files changed

+43
-2
lines changed

src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -762,6 +762,7 @@ private function addTranslatorSection(ArrayNodeDefinition $rootNode)
762762
->end()
763763
->booleanNode('logging')->defaultValue(false)->end()
764764
->scalarNode('formatter')->defaultValue('translator.formatter.default')->end()
765+
->scalarNode('cache_dir')->defaultValue('%kernel.cache_dir%/translations')->end()
765766
->scalarNode('default_path')
766767
->info('The default path used to load translations')
767768
->defaultValue('%kernel.project_dir%/translations')

src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1118,6 +1118,10 @@ private function registerTranslatorConfiguration(array $config, ContainerBuilder
11181118
$translator = $container->findDefinition('translator.default');
11191119
$translator->addMethodCall('setFallbackLocales', [$config['fallbacks'] ?: [$defaultLocale]]);
11201120

1121+
$defaultOptions = $translator->getArgument(4);
1122+
$defaultOptions['cache_dir'] = $config['cache_dir'];
1123+
$translator->setArgument(4, $defaultOptions);
1124+
11211125
$container->setParameter('translator.logging', $config['logging']);
11221126
$container->setParameter('translator.default_path', $config['default_path']);
11231127

src/Symfony/Bundle/FrameworkBundle/Resources/config/schema/symfony-1.0.xsd

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,7 @@
186186
<xsd:attribute name="fallback" type="xsd:string" />
187187
<xsd:attribute name="logging" type="xsd:boolean" />
188188
<xsd:attribute name="formatter" type="xsd:string" />
189+
<xsd:attribute name="cache-dir" type="xsd:string" />
189190
</xsd:complexType>
190191

191192
<xsd:complexType name="validation">

src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/ConfigurationTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,7 @@ protected static function getBundleDefaultConfig()
241241
'translator' => [
242242
'enabled' => !class_exists(FullStack::class),
243243
'fallbacks' => [],
244+
'cache_dir' => '%kernel.cache_dir%/translations',
244245
'logging' => false,
245246
'formatter' => 'translator.formatter.default',
246247
'paths' => [],

src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/full.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
'enabled' => true,
4747
'fallback' => 'fr',
4848
'paths' => ['%kernel.project_dir%/Fixtures/translations'],
49+
'cache_dir' => '%kernel.cache_dir%/translations',
4950
],
5051
'validation' => [
5152
'enabled' => true,
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?php
2+
3+
$container->loadFromExtension('framework', [
4+
'translator' => [
5+
'cache_dir' => null,
6+
],
7+
]);

src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/full.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
</framework:format>
2727
</framework:request>
2828
<framework:assets version="v1" />
29-
<framework:translator enabled="true" fallback="fr" logging="true">
29+
<framework:translator enabled="true" fallback="fr" logging="true" cache-dir="%kernel.cache_dir%/translations">
3030
<framework:path>%kernel.project_dir%/Fixtures/translations</framework:path>
3131
</framework:translator>
3232
<framework:validation enabled="true" />
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?xml version="1.0" ?>
2+
3+
<container xmlns="http://symfony.com/schema/dic/services"
4+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
5+
xmlns:framework="http://symfony.com/schema/dic/symfony"
6+
xsi:schemaLocation="http://symfony.com/schema/dic/services https://symfony.com/schema/dic/services/services-1.0.xsd
7+
http://symfony.com/schema/dic/symfony https://symfony.com/schema/dic/symfony/symfony-1.0.xsd">
8+
9+
<framework:config secret="s3cr3t">
10+
<framework:translator enabled="true" fallback="fr" logging="true" cache-dir="null" />
11+
</framework:config>
12+
</container>

src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/full.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ framework:
3636
enabled: true
3737
fallback: fr
3838
default_path: '%kernel.project_dir%/translations'
39+
cache_dir: '%kernel.cache_dir%/translations'
3940
paths: ['%kernel.project_dir%/Fixtures/translations']
4041
validation:
4142
enabled: true
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
framework:
2+
translator:
3+
cache_dir: ~

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy