made the charset overridable (closes #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'; }
This commit is contained in:
parent
81fe2ff8e2
commit
d9439aba71
@ -46,7 +46,21 @@ class Configuration implements ConfigurationInterface
|
||||
|
||||
$rootNode
|
||||
->children()
|
||||
->scalarNode('charset')->info('general configuration')->end()
|
||||
->scalarNode('charset')
|
||||
->defaultNull()
|
||||
->beforeNormalization()
|
||||
->ifTrue(function($v) { return null !== $v; })
|
||||
->then(function($v) {
|
||||
$message = 'The charset setting is deprecated. Just remove it from your configuration file.';
|
||||
|
||||
if ('UTF-8' !== $v) {
|
||||
$messages .= sprintf(' You need to define a getCharset() method in your Application Kernel class that returns "%s".', $v);
|
||||
}
|
||||
|
||||
throw new \RuntimeException($message);
|
||||
})
|
||||
->end()
|
||||
->end()
|
||||
->scalarNode('trust_proxy_headers')->defaultFalse()->end()
|
||||
->scalarNode('secret')->isRequired()->end()
|
||||
->scalarNode('ide')->defaultNull()->end()
|
||||
|
@ -60,9 +60,6 @@ class FrameworkExtension extends Extension
|
||||
$configuration = $this->getConfiguration($configs, $container);
|
||||
$config = $this->processConfiguration($configuration, $configs);
|
||||
|
||||
if (isset($config['charset'])) {
|
||||
$container->setParameter('kernel.charset', $config['charset']);
|
||||
}
|
||||
$container->setParameter('kernel.secret', $config['secret']);
|
||||
|
||||
$container->setParameter('kernel.trust_proxy_headers', $config['trust_proxy_headers']);
|
||||
|
@ -21,6 +21,7 @@
|
||||
<xsd:element name="annotations" type="annotations" minOccurs="0" maxOccurs="1" />
|
||||
</xsd:all>
|
||||
|
||||
<!-- charset is deprecated and will be removed in 2.2 -->
|
||||
<xsd:attribute name="charset" type="xsd:string" />
|
||||
<xsd:attribute name="trust-proxy-headers" type="xsd:string" />
|
||||
<xsd:attribute name="ide" type="xsd:string" />
|
||||
|
@ -1,5 +1,4 @@
|
||||
framework:
|
||||
charset: UTF-8
|
||||
secret: test
|
||||
csrf_protection:
|
||||
enabled: true
|
||||
|
@ -1,5 +1,4 @@
|
||||
framework:
|
||||
charset: UTF-8
|
||||
secret: test
|
||||
csrf_protection:
|
||||
enabled: true
|
||||
|
@ -4,6 +4,7 @@ CHANGELOG
|
||||
2.1.0
|
||||
-----
|
||||
|
||||
* [BC BREAK] the charset is now configured via the Kernel::getCharset() method
|
||||
* [BC BREAK] the current locale for the user is not stored anymore in the session
|
||||
* added the HTTP method to the profiler storage
|
||||
* updated all listeners to implement EventSubscriberInterface
|
||||
|
@ -467,6 +467,18 @@ abstract class Kernel implements KernelInterface, TerminableInterface
|
||||
return $this->rootDir.'/logs';
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the charset of the application.
|
||||
*
|
||||
* @return string The charset
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
public function getCharset()
|
||||
{
|
||||
return 'UTF-8';
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the data structures related to the bundle management.
|
||||
*
|
||||
@ -601,7 +613,7 @@ abstract class Kernel implements KernelInterface, TerminableInterface
|
||||
'kernel.cache_dir' => $this->getCacheDir(),
|
||||
'kernel.logs_dir' => $this->getLogDir(),
|
||||
'kernel.bundles' => $bundles,
|
||||
'kernel.charset' => 'UTF-8',
|
||||
'kernel.charset' => $this->getCharset(),
|
||||
'kernel.container_class' => $this->getContainerClass(),
|
||||
),
|
||||
$this->getEnvParameters()
|
||||
|
@ -196,4 +196,13 @@ interface KernelInterface extends HttpKernelInterface, \Serializable
|
||||
* @api
|
||||
*/
|
||||
function getLogDir();
|
||||
|
||||
/**
|
||||
* Gets the charset of the application.
|
||||
*
|
||||
* @return string The charset
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
function getCharset();
|
||||
}
|
||||
|
Reference in New Issue
Block a user