Class

eZ\Bundle\EzPublishCoreBundle\DependencyInjection\Configuration\SiteAccessAware\Contextualizer

class Contextualizer implements ContextualizerInterface

Methods

__construct(ContainerInterface $containerBuilder, $namespace, $siteAccessNodeName, array $availableSiteAccesses, array $groupsBySiteAccess)

setContextualParameter(string $parameterName, string $scope, mixed $value)

Defines a contextual parameter in the container for given scope in current namespace.

mixed mapSetting(string $id, array $config)

Maps a semantic setting to internal format for all declared scopes.

mapConfigArray(string $id, array $config, int $options)

Maps semantic array settings to internal format, and merges them between scopes.

setContainer(ContainerInterface $container)

ContainerInterface getContainer()

setSiteAccessNodeName(string $scopeNodeName)

Injects the name of the node under which scope based (semantic) configuration takes place.

string getSiteAccessNodeName()

setNamespace(string $namespace)

Injects namespace for internal settings.

string getNamespace()

setAvailableSiteAccesses(array $availableSiteAccesses)

Injects registered SiteAccesses (i.e.

array getAvailableSiteAccesses()

setGroupsBySiteAccess(array $groupsBySiteAccess)

Injects names of registered SiteAccess groups, indexed by SiteAccess.

array getGroupsBySiteAccess()

Details

at line 43
public __construct(ContainerInterface $containerBuilder, $namespace, $siteAccessNodeName, array $availableSiteAccesses, array $groupsBySiteAccess)

Parameters

ContainerInterface $containerBuilder
$namespace
$siteAccessNodeName
array $availableSiteAccesses
array $groupsBySiteAccess

at line 57
public setContextualParameter(string $parameterName, string $scope, mixed $value)

Defines a contextual parameter in the container for given scope in current namespace.

Resulting parameter will have format .. .

```php <?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' );
    $processor->mapConfig(
        $config,
        function ( array $scopeSettings, $currentScope, SiteAccessAware\ContextualizerInterface $contextualizer )
        {
            // Value of 'some_semantic_parameter' will be stored as a container parameter under
            // key acme_demo.<$currentScope>.my_internal_parameter
            $contextualizer->setContextualParameter( 'my_internal_parameter', $currentScope, $scopeSettings['some_semantic_parameter'] );
        }
    );
}

} ```

Parameters

string $parameterName
string $scope
mixed $value

at line 62
public mixed mapSetting(string $id, array $config)

Maps a semantic setting to internal format for all declared scopes.

Resulting parameter will have format .. .

Parameters

string $id Id of the setting to map. Note that it will be used to identify the semantic setting in $config and to define the internal setting in the container (..<$id>)
array $config Full semantic configuration array for current bundle.

Return Value

mixed

at line 71
public mapConfigArray(string $id, array $config, int $options)

Maps semantic array settings to internal format, and merges them between scopes.

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:

To calculate the precedence of siteaccess groups, they are alphabetically sorted.

Example:

```yaml acmedemo: system: mysiteaccessgroup: foosetting: 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 acmedemo.mysiteaccess.foosetting: foo: "bar" some: "thing" aninteger: 456 enabled: true

acmedemo.mysiteaccessgorup.foosetting foo: "bar" some: "thing" an_integer: 123 enabled: false ```

Parameters

string $id Id of the setting array to map. Note that it will be used to identify the semantic setting in $config and to define the internal setting in the container (..<$id>)
array $config Full semantic configuration array for current bundle.
int $options Bit mask of options (see constants of the interface)

at line 252
public setContainer(ContainerInterface $container)

Parameters

ContainerInterface $container

at line 257
public ContainerInterface getContainer()

Return Value

ContainerInterface

at line 262
public setSiteAccessNodeName(string $scopeNodeName)

Injects the name of the node under which scope based (semantic) configuration takes place.

Parameters

string $scopeNodeName

at line 267
public string getSiteAccessNodeName()

Return Value

string

at line 272
public setNamespace(string $namespace)

Injects namespace for internal settings.

Registered internal settings always have the format .. e.g. ezsettings.default.session.

Parameters

string $namespace

at line 277
public string getNamespace()

Return Value

string

at line 282
public setAvailableSiteAccesses(array $availableSiteAccesses)

Injects registered SiteAccesses (i.e.

configuration scopes).

Parameters

array $availableSiteAccesses

at line 287
public array getAvailableSiteAccesses()

Return Value

array

at line 292
public setGroupsBySiteAccess(array $groupsBySiteAccess)

Injects names of registered SiteAccess groups, indexed by SiteAccess.

i.e. Which groups a SiteAccess is part of.

Parameters

array $groupsBySiteAccess

at line 297
public array getGroupsBySiteAccess()

Return Value

array