8000 merged branch fabpot/charset-fix (PR #4716) · mageekguy/symfony@bf59b86 · GitHub
[go: up one dir, main page]

Skip to content

Commit bf59b86

Browse files
committed
merged branch fabpot/charset-fix (PR symfony#4716)
Commits ------- d9439ab made the charset overridable (closes symfony#2072) Discussion ---------- made the charset overridable (closes symfony#2072) The charset was configurable in a configuration file but it never worked: framework: charset: ISO-8859-1 Now, like for the cache and log dirs, you can configure the charset by overriding the getCharset() method in the app kernel: public function getCharset() { return 'ISO-8859-1'; } --------------------------------------------------------------------------- by fabpot at 2012-07-03T07:26:04Z See symfony#2072 for the previous attempts to fix this issue.
2 parents f47b9a6 + d9439ab commit bf59b86

File tree

8 files changed

+39
-7
lines changed

8 files changed

+39
-7
lines changed

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

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,21 @@ public function getConfigTreeBuilder()
4646

4747
$rootNode
4848
->children()
49-
->scalarNode('charset')->info('general configuration')->end()
49+
->scalarNode('charset')
50+
->defaultNull()
51+
->beforeNormalization()
52+
->ifTrue(function($v) { return null !== $v; })
53+
->then(function($v) {
54+
$message = 'The charset setting is deprecated. Just remove it from your configuration file.';
55+
56+
if ('UTF-8' !== $v) {
57+
$messages .= sprintf(' You need to define a getCharset() method in your Application Kernel class that returns "%s".', $v);
58+
}
59+
60+
throw new \RuntimeException($message);
61+
})
62+
->end()
63+
->end()
5064
->scalarNode('trust_proxy_headers')->defaultFalse()->end()
5165
->scalarNode('secret')->isRequired()->end()
5266
->scalarNode('ide')->defaultNull()->end()

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

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,6 @@ public function load(array $configs, ContainerBuilder $container)
6060
$configuration = $this->getConfiguration($configs, $container);
6161
$config = $this->processConfiguration($configuration, $configs);
6262

63-
if (isset($config['charset'])) {
64-
$container->setParameter('kernel.charset', $config['charset']);
65-
}
6663
$container->setParameter('kernel.secret', $config['secret']);
6764

6865
$container->setParameter('kernel.trust_proxy_headers', $config['trust_proxy_headers']);

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
@@ -21,6 +21,7 @@
2121
<xsd:element name="annotations" type="annotations" minOccurs="0" maxOccurs="1" />
2222
</xsd:all>
2323

24+
<!-- charset is deprecated and will be removed in 2.2 -->
2425
<xsd:attribute name="charset" type="xsd:string" />
2526
<xsd:attribute name="trust-proxy-headers" type="xsd:string" />
2627
<xsd:attribute name="ide" type="xsd:string" />

src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/config/framework.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
framework:
2-
charset: UTF-8
32
secret: test
43
csrf_protection:
54
enabled: true

src/Symfony/Bundle/SecurityBundle/Tests/Functional/app/config/framework.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
framework:
2-
charset: UTF-8
32
secret: test
43
csrf_protection:
54
enabled: true

src/Symfony/Component/HttpKernel/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ CHANGELOG
44
2.1.0
55
-----
66

7+
* [BC BREAK] the charset is now configured via the Kernel::getCharset() method
78
* [BC BREAK] the current locale for the user is not stored anymore in the session
89
* added the HTTP method to the profiler storage
910
* updated all listeners to implement EventSubscriberInterface

src/Symfony/Component/HttpKernel/Kernel.php

Lines changed: 13 additions & 1 deletion
< 9E88 td data-grid-cell-id="diff-842527ea5582808ca82ff360aa1f7ceaa44584c9c4b4edd6c27381f62d834d3c-469-480-1" data-selected="false" role="gridcell" style="background-color:var(--diffBlob-additionNum-bgColor, var(--diffBlob-addition-bgColor-num));text-align:center" tabindex="-1" valign="top" class="focusable-grid-cell diff-line-number position-relative left-side">480
Original file line numberDiff line numberDiff line change
@@ -467,6 +467,18 @@ public function getLogDir()
467467
return $this->rootDir.'/logs';
468468
}
469469

470+
/**
471+
* Gets the charset of the application.
472+
*
473+
* @return string The charset
474+
*
475+
* @api
476+
*/
477+
public function getCharset()
478+
{
479+
return 'UTF-8';
+
}
481+
470482
/**
471483
* Initializes the data structures related to the bundle management.
472484
*
@@ -601,7 +613,7 @@ protected function getKernelParameters()
601613
'kernel.cache_dir' => $this->getCacheDir(),
602614
'kernel.logs_dir' => $this->getLogDir(),
603615
'kernel.bundles' => $bundles,
604-
'kernel.charset' => 'UTF-8',
616+
'kernel.charset' => $this->getCharset(),
605617
'kernel.container_class' => $this->getContainerClass(),
606618
),
607619
$this->getEnvParameters()

src/Symfony/Component/HttpKernel/KernelInterface.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,4 +196,13 @@ function getCacheDir();
196196
* @api
197197
*/
198198
function getLogDir();
199+
200+
/**
201+
* Gets the charset of the application.
202+
*
203+
* @return string The charset
204+
*
205+
* @api
206+
*/
207+
function getCharset();
199208
}

0 commit comments

Comments
 (0)
0