Exponential 5.x Kernel 7.5.40 Exponential New Stack (Symfony-based) Kernel — PHP Class Reference

Languages.php
Go to the documentation of this file.
1 <?php
2
7 namespace eZ\Bundle\EzPublishCoreBundle\DependencyInjection\Configuration\Parser;
8
9 use eZ\Bundle\EzPublishCoreBundle\DependencyInjection\Configuration\AbstractParser;
10 use eZ\Bundle\EzPublishCoreBundle\DependencyInjection\Configuration\SiteAccessAware\ContextualizerInterface;
11 use Symfony\Component\Config\Definition\Builder\NodeBuilder;
12
13 class Languages extends AbstractParser
14 {
15 private $siteAccessesByLanguages = [];
16
22 public function addSemanticConfig(NodeBuilder $nodeBuilder)
23 {
24 $nodeBuilder
25 ->arrayNode('languages')
26 ->requiresAtLeastOneElement()
27 ->info('Available languages, in order of precedence')
28 ->example(['fre-FR', 'eng-GB'])
29 ->prototype('scalar')->end()
30 ->end()
31 ->arrayNode('translation_siteaccesses')
32 ->info('List of "translation siteaccesses" which can be used by language switcher.')
33 ->example(['french_siteaccess', 'english_siteaccess'])
34 ->prototype('scalar')->end()
35 ->end();
36 }
37
38 public function preMap(array $config, ContextualizerInterface $contextualizer)
39 {
40 $contextualizer->mapConfigArray('languages', $config, ContextualizerInterface::UNIQUE);
41 $contextualizer->mapConfigArray('translation_siteaccesses', $config, ContextualizerInterface::UNIQUE);
42
43 $container = $contextualizer->getContainer();
44 if ($container->hasParameter('ezpublish.siteaccesses_by_language')) {
45 $this->siteAccessesByLanguages = $container->getParameter('ezpublish.siteaccesses_by_language');
46 }
47 }
48
49 public function mapConfig(array &$scopeSettings, $currentScope, ContextualizerInterface $contextualizer)
50 {
51 $container = $contextualizer->getContainer();
52 if ($container->hasParameter("ezsettings.$currentScope.languages")) {
53 $languages = $container->getParameter("ezsettings.$currentScope.languages");
54 $mainLanguage = array_shift($languages);
55 if ($mainLanguage) {
56 $this->siteAccessesByLanguages[$mainLanguage][] = $currentScope;
57 }
58 }
59 }
60
61 public function postMap(array $config, ContextualizerInterface $contextualizer)
62 {
63 $contextualizer->getContainer()->setParameter(
64 'ezpublish.siteaccesses_by_language',
65 $this->siteAccessesByLanguages
66 );
67 }
68 }
eZ\Bundle\EzPublishCoreBundle\DependencyInjection\Configuration\AbstractParser
Definition: AbstractParser.php:12
eZ\Bundle\EzPublishCoreBundle\DependencyInjection\Configuration\Parser\Languages
Definition: Languages.php:14
eZ\Bundle\EzPublishCoreBundle\DependencyInjection\Configuration\Parser\Languages\mapConfig
mapConfig(array &$scopeSettings, $currentScope, ContextualizerInterface $contextualizer)
Does semantic config to internal container parameters mapping for $currentScope.
Definition: Languages.php:49
eZ\Bundle\EzPublishCoreBundle\DependencyInjection\Configuration\Parser\Languages\postMap
postMap(array $config, ContextualizerInterface $contextualizer)
This method is called by the ConfigurationProcessor after looping over available scopes.
Definition: Languages.php:61
eZ\Bundle\EzPublishCoreBundle\DependencyInjection\Configuration\Parser\Languages\preMap
preMap(array $config, ContextualizerInterface $contextualizer)
This method is called by the ConfigurationProcessor before looping over available scopes.
Definition: Languages.php:38
eZ\Bundle\EzPublishCoreBundle\DependencyInjection\Configuration\Parser\Languages\$siteAccessesByLanguages
$siteAccessesByLanguages
Definition: Languages.php:15
eZ\Bundle\EzPublishCoreBundle\DependencyInjection\Configuration\Parser\Languages\addSemanticConfig
addSemanticConfig(NodeBuilder $nodeBuilder)
Adds semantic configuration definition.
Definition: Languages.php:22
eZ\Bundle\EzPublishCoreBundle\DependencyInjection\Configuration\SiteAccessAware\ContextualizerInterface
Definition: ContextualizerInterface.php:12
eZ\Bundle\EzPublishCoreBundle\DependencyInjection\Configuration\SiteAccessAware\ContextualizerInterface\mapConfigArray
mapConfigArray($id, array $config, $options=0)
Maps semantic array settings to internal format, and merges them between scopes.
eZ\Bundle\EzPublishCoreBundle\DependencyInjection\Configuration\SiteAccessAware\ContextualizerInterface\getContainer
getContainer()
eZ\Bundle\EzPublishCoreBundle\DependencyInjection\Configuration\Parser
Definition: AbstractFieldTypeParser.php:7
Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.