setGroupsBySiteAccess() public static method

Important: Groups need to be set before ConfigurationProcessor to be constructed by a bundle to set its configuration up.
public static setGroupsBySiteAccess ( array $groupsBySiteAccess )
$groupsBySiteAccess array
 protected function setUp()
 {
     parent::setUp();
     $this->availableSiteAccesses = array('sa1', 'sa2', 'sa3');
     ConfigurationProcessor::setAvailableSiteAccesses($this->availableSiteAccesses);
     $this->groupsBySiteAccess = array('sa2' => array('sa_group'), 'sa3' => array('sa_group'));
     ConfigurationProcessor::setGroupsBySiteAccess($this->groupsBySiteAccess);
     $this->configResolver = new ConfigResolver($this->groupsBySiteAccess, 'ezsettings');
 }
 public function testConstruct()
 {
     $namespace = 'ez_test';
     $siteAccessNodeName = 'foo';
     $container = $this->getMock('Symfony\\Component\\DependencyInjection\\ContainerInterface');
     $siteAccessList = array('test', 'bar');
     $groupsBySa = array('test' => array('group1', 'group2'), 'bar' => array('group1', 'group3'));
     ConfigurationProcessor::setAvailableSiteAccesses($siteAccessList);
     ConfigurationProcessor::setGroupsBySiteAccess($groupsBySa);
     $processor = new ConfigurationProcessor($container, $namespace, $siteAccessNodeName);
     $contextualizer = $processor->getContextualizer();
     $this->assertInstanceOf('eZ\\Bundle\\EzPublishCoreBundle\\DependencyInjection\\Configuration\\SiteAccessAware\\ContextualizerInterface', $contextualizer);
     $this->assertSame($container, $contextualizer->getContainer());
     $this->assertSame($namespace, $contextualizer->getNamespace());
     $this->assertSame($siteAccessNodeName, $contextualizer->getSiteAccessNodeName());
     $this->assertSame($siteAccessList, $contextualizer->getAvailableSiteAccesses());
     $this->assertSame($groupsBySa, $contextualizer->getGroupsBySiteAccess());
 }
 public function testGlobalLayout()
 {
     ConfigurationProcessor::setAvailableSiteAccesses(array('sa1', 'sa2', 'sa3'));
     $groupsBySiteAccess = array('sa2' => array('sa_group'));
     ConfigurationProcessor::setGroupsBySiteAccess($groupsBySiteAccess);
     $layoutSa1 = 'module_layout_for_sa1.html.twig';
     $layoutSaGroup = 'module_layout_for_sa_group.html.twig';
     $defaultLayout = null;
     $config = array('enabled' => true, 'root_dir' => __DIR__, 'system' => array('sa1' => array('templating' => array('module_layout' => $layoutSa1)), 'sa_group' => array('templating' => array('module_layout' => $layoutSaGroup))));
     $this->load($config);
     $this->assertContainerBuilderHasParameter('ezpublish_legacy.default.module_default_layout', $defaultLayout);
     // Testing values with real ConfigResolver
     $configResolver = new ConfigResolver($groupsBySiteAccess, 'foo');
     $configResolver->setContainer($this->container);
     $this->assertSame($layoutSa1, $configResolver->getParameter('module_default_layout', 'ezpublish_legacy', 'sa1'));
     $this->assertSame($layoutSaGroup, $configResolver->getParameter('module_default_layout', 'ezpublish_legacy', 'sa2'));
     $this->assertSame($defaultLayout, $configResolver->getParameter('module_default_layout', 'ezpublish_legacy', 'sa3'));
 }
 private function registerSiteAccessConfiguration(array $config, ContainerBuilder $container)
 {
     if (!isset($config['siteaccess'])) {
         $config['siteaccess'] = array();
         $config['siteaccess']['list'] = array('setup');
         $config['siteaccess']['default_siteaccess'] = 'setup';
         $config['siteaccess']['groups'] = array();
         $config['siteaccess']['match'] = null;
     }
     $container->setParameter('ezpublish.siteaccess.list', $config['siteaccess']['list']);
     ConfigurationProcessor::setAvailableSiteAccesses($config['siteaccess']['list']);
     $container->setParameter('ezpublish.siteaccess.default', $config['siteaccess']['default_siteaccess']);
     $container->setParameter('ezpublish.siteaccess.match_config', $config['siteaccess']['match']);
     // Register siteaccess groups + reverse
     $container->setParameter('ezpublish.siteaccess.groups', $config['siteaccess']['groups']);
     $groupsBySiteaccess = array();
     foreach ($config['siteaccess']['groups'] as $groupName => $groupMembers) {
         foreach ($groupMembers as $member) {
             if (!isset($groupsBySiteaccess[$member])) {
                 $groupsBySiteaccess[$member] = array();
             }
             $groupsBySiteaccess[$member][] = $groupName;
         }
     }
     $container->setParameter('ezpublish.siteaccess.groups_by_siteaccess', $groupsBySiteaccess);
     ConfigurationProcessor::setGroupsBySiteAccess($groupsBySiteaccess);
 }
 public function testLoadWithCssConfig()
 {
     ConfigurationProcessor::setAvailableSiteAccesses(['sa1', 'sa2', 'sa3']);
     ConfigurationProcessor::setGroupsBySiteAccess(['sa2' => ['sa_group'], 'sa3' => ['sa_group']]);
     $defaultFiles = ['def1.css', 'def2.css'];
     $default = ['css' => ['files' => $defaultFiles]];
     $sa1Files = ['sa1.css'];
     $sa1 = ['css' => ['files' => $sa1Files]];
     $sa2 = [];
     $sa3Files = ['sa3.css'];
     $sa3 = ['css' => ['files' => $sa3Files]];
     $groupFiles = ['group.css'];
     $group = ['css' => ['files' => $groupFiles]];
     $this->load(['system' => ['default' => $default, 'sa1' => $sa1, 'sa2' => $sa2, 'sa3' => $sa3, 'sa_group' => $group]]);
     $this->assertContainerBuilderHasParameter('ez_platformui.default.css.files', $defaultFiles);
     $this->assertContainerBuilderHasParameter('ez_platformui.sa1.css.files', array_merge($defaultFiles, $sa1Files));
     $this->assertContainerBuilderHasParameter('ez_platformui.sa2.css.files', array_merge($defaultFiles, $groupFiles));
     $this->assertContainerBuilderHasParameter('ez_platformui.sa3.css.files', array_merge($defaultFiles, $groupFiles, $sa3Files));
     $this->assertFalse($this->container->has('ez_platformui.sa_group.css.files'));
 }