This is useful to get a setting for a specific siteaccess for example. It will check the different scopes available for a given namespace to find the appropriate parameter. To work, the dynamic setting must comply internally to the following name format : "..parameter.name". - is the namespace for your dynamic setting. Defaults to "ezsettings", but can be anything. - is basically the siteaccess name you want your parameter value to apply to. Can also be "global" for a global override. Another scope is used internally: "default". This is the generic fallback. The resolve scope order is the following: 1. "global" 2. SiteAccess name 3. "default"
Наследование: implements eZ\Publish\Core\MVC\Symfony\Configuration\VersatileScopeInterface, implements eZ\Publish\Core\MVC\Symfony\SiteAccess\SiteAccessAware, implements Symfony\Component\DependencyInjection\ContainerAwareInterface, use trait Symfony\Component\DependencyInjection\ContainerAwareTrait
 /**
  * @param string $defaultNS
  * @param int $undefinedStrategy
  * @param array $groupsBySiteAccess
  *
  * @return \eZ\Bundle\EzPublishCoreBundle\DependencyInjection\Configuration\ConfigResolver
  */
 private function getResolver($defaultNS = 'ezsettings', $undefinedStrategy = ConfigResolver::UNDEFINED_STRATEGY_EXCEPTION, array $groupsBySiteAccess = array())
 {
     $configResolver = new ConfigResolver($groupsBySiteAccess, $defaultNS, $undefinedStrategy);
     $configResolver->setSiteAccess($this->siteAccess);
     $configResolver->setContainer($this->containerMock);
     return $configResolver;
 }
 /**
  * Method for parsing ezimage field.
  *
  * @param \eZ\Publish\API\Repository\Values\Content\Field $field
  * @param \eZ\Publish\API\Repository\Values\Content\Content $content
  *
  * @return string
  *
  * @throws \eZ\Publish\API\Repository\Exceptions\InvalidVariationException
  * @throws \eZ\Publish\Core\MVC\Exception\SourceImageNotFoundException
  */
 public function ezimage(Field $field, Content $content)
 {
     if (!isset($field->value->id)) {
         return '';
     }
     $variations = $this->configResolver->getParameter('image_variations');
     $variation = 'original';
     $requestedVariation = $this->request->getCurrentRequest()->get('image');
     if (null !== $requestedVariation || in_array($requestedVariation, array_keys($variations))) {
         $variation = $requestedVariation;
     }
     try {
         return $this->imageVariationService->getVariation($field, $content->versionInfo, $variation)->uri;
     } catch (SourceImageNotFoundException $exception) {
         return '';
     }
 }
 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'));
 }
 public function testFacebook()
 {
     $defaultWidth = 470;
     $appIdSa1 = 123;
     $colorSchemeSa1 = 'dark';
     $includeSdkSa1 = false;
     $defaultNumPosts = 10;
     $appIdSa2 = 456;
     $numPostsSa2 = 20;
     $includeSdkSa2 = true;
     $widthSa2 = 471;
     $appIdSaGroup = 789;
     $includeSdkSaGroup = false;
     $numPostsSaGroup = 15;
     $defaultTemplate = 'EzSystemsCommentsBundle::facebook.html.twig';
     $templateSa1 = 'tyron_half_face_book.html.twig';
     $templateSa2 = 'cerseis_facebook.html.twig';
     $widthSaGroup = 570;
     $config = array('system' => array('sa1' => array('default_provider' => 'facebook', 'facebook' => array('app_id' => $appIdSa1, 'color_scheme' => $colorSchemeSa1, 'include_sdk' => $includeSdkSa1, 'template' => $templateSa1)), 'sa2' => array('default_provider' => 'disqus', 'facebook' => array('app_id' => $appIdSa2, 'num_posts' => $numPostsSa2, 'include_sdk' => $includeSdkSa2, 'template' => $templateSa2, 'width' => $widthSa2)), 'sa_group' => array('default_provider' => 'facebook', 'facebook' => array('app_id' => $appIdSaGroup, 'include_sdk' => $includeSdkSaGroup, 'num_posts' => $numPostsSaGroup, 'width' => $widthSaGroup))));
     $this->load($config);
     $this->assertSame('facebook', $this->configResolver->getParameter('default_provider', 'ez_comments', 'sa1'));
     $this->assertSame('disqus', $this->configResolver->getParameter('default_provider', 'ez_comments', 'sa2'));
     $this->assertSame('facebook', $this->configResolver->getParameter('default_provider', 'ez_comments', 'sa3'));
     $this->assertSame($appIdSa1, $this->configResolver->getParameter('facebook.app_id', 'ez_comments', 'sa1'));
     $this->assertSame($appIdSa2, $this->configResolver->getParameter('facebook.app_id', 'ez_comments', 'sa2'));
     $this->assertSame($appIdSaGroup, $this->configResolver->getParameter('facebook.app_id', 'ez_comments', 'sa3'));
     $this->assertSame($colorSchemeSa1, $this->configResolver->getParameter('facebook.color_scheme', 'ez_comments', 'sa1'));
     $this->assertSame('light', $this->configResolver->getParameter('facebook.color_scheme', 'ez_comments', 'sa2'));
     $this->assertSame('light', $this->configResolver->getParameter('facebook.color_scheme', 'ez_comments', 'sa3'));
     $this->assertSame($includeSdkSa1, $this->configResolver->getParameter('facebook.include_sdk', 'ez_comments', 'sa1'));
     $this->assertSame($includeSdkSa2, $this->configResolver->getParameter('facebook.include_sdk', 'ez_comments', 'sa2'));
     $this->assertSame($includeSdkSaGroup, $this->configResolver->getParameter('facebook.include_sdk', 'ez_comments', 'sa3'));
     $this->assertSame($templateSa1, $this->configResolver->getParameter('facebook.default_template', 'ez_comments', 'sa1'));
     $this->assertSame($templateSa2, $this->configResolver->getParameter('facebook.default_template', 'ez_comments', 'sa2'));
     $this->assertSame($defaultTemplate, $this->configResolver->getParameter('facebook.default_template', 'ez_comments', 'sa3'));
     $this->assertSame($defaultWidth, $this->configResolver->getParameter('facebook.width', 'ez_comments', 'sa1'));
     $this->assertSame($widthSa2, $this->configResolver->getParameter('facebook.width', 'ez_comments', 'sa2'));
     $this->assertSame($widthSaGroup, $this->configResolver->getParameter('facebook.width', 'ez_comments', 'sa3'));
     $this->assertSame($defaultNumPosts, $this->configResolver->getParameter('facebook.num_posts', 'ez_comments', 'sa1'));
     $this->assertSame($numPostsSa2, $this->configResolver->getParameter('facebook.num_posts', 'ez_comments', 'sa2'));
     $this->assertSame($numPostsSaGroup, $this->configResolver->getParameter('facebook.num_posts', 'ez_comments', 'sa3'));
 }
 /**
  * Asserts a parameter from ConfigResolver has expected value for given scope.
  *
  * @param string $parameterName
  * @param mixed $expectedValue
  * @param string $scope SiteAccess name, group, default or global
  * @param bool $assertSame Set to false if you want to use assertEquals() instead of assertSame()
  */
 protected function assertConfigResolverParameterValue($parameterName, $expectedValue, $scope, $assertSame = true)
 {
     $assertMethod = $assertSame ? 'assertSame' : 'assertEquals';
     $this->{$assertMethod}($expectedValue, $this->configResolver->getParameter($parameterName, 'ezsettings', $scope));
 }