Persistence
Edit this pageThe CoreBundle lets you to centrally configure the persistence layer for all CMF bundles.
To make the PHPCR-ODM the default persistence layer for all CMF bundles add the following to your main configuration file:
1 2 3 4
# app/config/config.yml
cmf_core:
persistence:
phpcr: ~
1 2 3 4 5 6 7 8 9 10 11
<!-- app/config/config.xml -->
<?xml version="1.0" charset="UTF-8" ?>
<container xmlns="http://symfony.com/schema/dic/services">
<config xmlns="http://cmf.symfony.com/schema/dic/core">
<persistence>
<phpcr />
</persistence>
</config>
</container>
1 2 3 4 5 6
// app/config/config.php
$container->loadFromExtension('cmf_core', [
'persistence' => [
'phpcr' => [],
],
]);
Persisting Documents in Different Languages
Refer to the PHPCR-ODM documentation for details on persisting documents in different languages.
Choosing a Global Translation Strategy
PHPCR-ODM supports multiple different strategies for persisting translations in the repository. When combining Bundles its possible that one ends up with a mix of different strategies which can make providing a generic search across this data more complicated and might also be less efficient depending on the number of different languages used in the system.
For this purpose the CoreBundle provides a Doctrine listener that can optionally enforce a single translation strategy for all documents:
1 2 3 4 5
# app/config/config.yml
cmf_core:
persistence:
phpcr:
translation_strategy: attribute
1 2 3 4 5 6 7 8 9 10 11
<!-- app/config/config.xml -->
<?xml version="1.0" charset="UTF-8" ?>
<container xmlns="http://symfony.com/schema/dic/services">
<config xmlns="http://cmf.symfony.com/schema/dic/core">
<persistence>
<phpcr translation-strategy="attribute"/>
</persistence>
</config>
</container>
1 2 3 4 5 6 7 8
// app/config/config.php
$container->loadFromExtension('cmf_core', [
'persistence' => [
'phpcr' => [
'translation_strategy' => 'attribute',
],
],
]);
Caution
Changing this setting when data was already persisted with a different translation strategy will require manually updating the current data to match that of the chosen translation strategy.
See the PHPCR-ODM documentation for more information.