public mapConfig ( array $config, eZ\Bundle\EzPublishCoreBundle\DependencyInjection\Configuration\SiteAccessAware\ConfigurationMapperInterface | callable $mapper ) | ||
$config | array | Parsed semantic configuration |
$mapper | eZ\Bundle\EzPublishCoreBundle\DependencyInjection\Configuration\SiteAccessAware\ConfigurationMapperInterface | callable | Mapper to use. Can be either an instance of ConfigurationMapper or a callable. HookableConfigurationMapper can also be used. In this case, preMap() and postMap() will be also called respectively before and after the mapping loop. If $mapper is a callable, the same arguments as defined in the signature defined in ConfigurationMapper interface will be passed: `array $scopeSettings, $currentScope, ContextualizerInterface $contextualizer` |
public function mapConfig(array $config, $mapper)
{
$mapperCallable = is_callable($mapper);
if (!$mapperCallable && !$mapper instanceof ConfigurationMapperInterface) {
throw new InvalidArgumentException('Configuration mapper must either be a callable or an instance of ConfigurationMapper.');
}
if ($mapper instanceof HookableConfigurationMapperInterface) {
$mapper->preMap($config, $this->contextualizer);
}
$scopeNodeName = $this->contextualizer->getSiteAccessNodeName();
foreach ($config[$scopeNodeName] as $currentScope => &$scopeSettings) {
if ($mapperCallable) {
call_user_func_array($mapper, array(&$scopeSettings, $currentScope, $this->contextualizer));
} else {
$mapper->mapConfig($scopeSettings, $currentScope, $this->contextualizer);
}
}
if ($mapper instanceof HookableConfigurationMapperInterface) {
$mapper->postMap($config, $this->contextualizer);
}
}
/** * {@inheritdoc} */ public function load(array $configs, ContainerBuilder $container) { $configuration = $this->getConfiguration($configs, $container); $config = $this->processConfiguration($configuration, $configs); $loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config')); $loader->load('services.yml'); $loader->load('slots.yml'); $loader->load('default_settings.yml'); if (isset($config['api_endpoint'])) { $container->setParameter('ez_recommendation.api_endpoint', $config['api_endpoint']); } if (isset($config['recommender']['api_endpoint'])) { $container->setParameter('ez_recommendation.recommender.api_endpoint', $config['recommender']['api_endpoint']); } if (isset($config['recommender']['consume_timeout'])) { $container->setParameter('ez_recommendation.recommender.consume_timeout', $config['recommender']['consume_timeout']); } if (isset($config['tracking']['script_url'])) { $container->setParameter('ez_recommendation.tracking.script_url', $config['tracking']['script_url']); } if (isset($config['tracking']['api_endpoint'])) { $container->setParameter('ez_recommendation.tracking.api_endpoint', $config['tracking']['api_endpoint']); } $processor = new ConfigurationProcessor($container, 'ez_recommendation'); $processor->mapConfig($config, new ConfigurationMapper()); }