This is useful when you have e.g. a hash of settings defined in a siteaccess group and you want an entry of
this hash, defined at the siteaccess or global level, to replace the one in the group.
Defined arrays are merged in the following scopes:
* default
* siteaccess groups
* siteaccess
* global
To calculate the precedence of siteaccess groups, they are alphabetically sorted.
Example:
yaml
acme_demo:
system:
my_siteaccess_group:
foo_setting:
foo: "bar"
some: "thing"
an_integer: 123
enabled: false
# Assuming my_siteaccess is part of my_siteaccess_group
my_siteaccess:
foo_setting:
an_integer: 456
enabled: true
In your DIC extension
php
namespace Acme\DemoBundle\DependencyInjection;
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Loader;
use eZ\Bundle\EzPublishCoreBundle\DependencyInjection\Configuration\SiteAccessAware;
class AcmeDemoExtension extends Extension
{
public function load( array $configs, ContainerBuilder $container )
{
$loader = new Loader\YamlFileLoader( $container, new FileLocator( __DIR__ . '/../Resources/config' ) );
$configuration = $this->getConfiguration( $configs, $container );
$config = $this->processConfiguration( $configuration, $configs );
...
$processor = new SiteAccessAware\ConfigurationProcessor( $container, 'acme_demo' );
$contextualizer = $processor->getContextualizer();
$contextualizer->mapConfigArray( 'foo_setting', $configs );
$processor->mapConfig(
$config,
function ( array $scopeSettings, $currentScope, SiteAccessAware\ContextualizerInterface $contextualizer )
{
...
}
);
}
}
This will result with having following parameters in the container:
yaml
acme_demo.my_siteaccess.foo_setting:
foo: "bar"
some: "thing"
an_integer: 456
enabled: true
acme_demo.my_siteaccess_gorup.foo_setting
foo: "bar"
some: "thing"
an_integer: 123
enabled: false