/**
  * {@inheritdoc}
  */
 public function process(ContainerBuilder $container)
 {
     $settings = $this->loadSettings($container);
     $container->getDefinition(self::CONFIG_DEFINITION_BAG_SERVICE)->replaceArgument(0, $settings);
     $providers = [];
     $taggedServices = $container->findTaggedServiceIds(self::CONFIG_PROVIDER_TAG_NAME);
     foreach ($taggedServices as $id => $attributes) {
         $providers[$attributes[0]['scope']][] = $id;
     }
     $processor = new ProcessorDecorator(new Processor(), $this->getDeclaredVariableNames($settings));
     foreach ($providers as $scope => $ids) {
         $config = $processor->process($this->loadConfig($container, $processor, $scope));
         foreach ($ids as $id) {
             $container->getDefinition($id)->replaceArgument(0, $config);
         }
     }
 }
 /**
  * {@inheritDoc}
  */
 public function process(ContainerBuilder $container)
 {
     $config = array();
     $processor = new ProcessorDecorator();
     foreach ($container->getParameter('kernel.bundles') as $bundle) {
         $reflection = new \ReflectionClass($bundle);
         if (is_file($file = dirname($reflection->getFilename()) . '/Resources/config/' . self::CONFIG_FILE_NAME)) {
             $bundleConfig = Yaml::parse(file_get_contents(realpath($file)));
             $config = $processor->merge($config, $bundleConfig);
         }
     }
     $taggedServices = $container->findTaggedServiceIds(FormProvider::TAG_NAME);
     if ($taggedServices) {
         $config = $processor->process($config);
         foreach ($taggedServices as $id => $attributes) {
             $container->getDefinition($id)->replaceArgument(0, $config);
         }
     }
 }
Esempio n. 3
0
 /**
  * @param string $configPath
  *
  * @return SystemConfigurationFormProvider
  */
 protected function getProviderWithConfigLoaded($configPath)
 {
     $config = Yaml::parse(file_get_contents($configPath));
     $processor = new ProcessorDecorator(new Processor(), ['some_field', 'some_another_field', 'some_ui_only_field', 'some_api_only_field']);
     $config = $processor->process($config);
     $subscriber = $this->getMockBuilder('Oro\\Bundle\\ConfigBundle\\Form\\EventListener\\ConfigSubscriber')->setMethods(array('__construct'))->disableOriginalConstructor()->getMock();
     $formType = new FormType($subscriber);
     $formFieldType = new FormFieldType();
     $useParentScope = new ParentScopeCheckbox();
     $extensions = array(new PreloadedExtension(array($formType->getName() => $formType, $formFieldType->getName() => $formFieldType, $useParentScope->getName() => $useParentScope), array()));
     $factory = Forms::createFormFactoryBuilder()->addExtensions($extensions)->addTypeExtension(new DataBlockExtension())->getFormFactory();
     $securityFacade = $this->getMockBuilder('Oro\\Bundle\\SecurityBundle\\SecurityFacade')->disableOriginalConstructor()->getMock();
     $provider = new SystemConfigurationFormProvider($config, $factory, $securityFacade);
     return $provider;
 }
 /**
  * @param string $configPath
  *
  * @return SystemConfigurationFormProvider
  */
 protected function getProviderWithConfigLoaded($configPath)
 {
     $config = Yaml::parse(file_get_contents($configPath));
     $processor = new ProcessorDecorator();
     $config = $processor->process($config);
     $subscriber = $this->getMockBuilder('Oro\\Bundle\\ConfigBundle\\Form\\EventListener\\ConfigSubscriber')->setMethods(['__construct'])->disableOriginalConstructor()->getMock();
     $formType = new FormType($subscriber);
     $formFieldType = new FormFieldType();
     $extensions = [new PreloadedExtension([$formType->getName() => $formType, $formFieldType->getName() => $formFieldType], [])];
     $factory = Forms::createFormFactoryBuilder()->addExtensions($extensions)->addTypeExtension(new DataBlockExtension())->getFormFactory();
     $securityFacade = $this->getMockBuilder('Oro\\Bundle\\SecurityBundle\\SecurityFacade')->disableOriginalConstructor()->getMock();
     $provider = new SystemConfigurationFormProvider($config, $factory, $securityFacade);
     return $provider;
 }
 /**
  * Parse config fixture and validate through processorDecorator
  *
  * @param string $path
  *
  * @return array
  */
 protected function getConfig($path)
 {
     $config = Yaml::parse(file_get_contents($path));
     $processor = new ProcessorDecorator();
     return $processor->process($config);
 }
 /**
  * Parse config fixture and validate through processorDecorator
  *
  * @param string $path
  *
  * @return array
  */
 protected function getConfig($path)
 {
     $config = Yaml::parse(file_get_contents($path));
     $processor = new ProcessorDecorator(new Processor(), ['some_field', 'some_another_field', 'some_ui_only_field', 'some_api_only_field']);
     return $processor->process($config);
 }